Max length of system.string

  • Thread starter Thread starter Qwert
  • Start date Start date
Qwert said:
is there a max length for a System.String?

I guess it is ~ 'Int32.MaxValue', because otherwise properties and methods
of the 'String' class would not work as expected any more.
 
The limit depends only on the amount of memory available.

so on my windows 2003 64 bit with 1.2 gb of memory and 15 Gb of free
harddisk space on the disk that contains the swapfile it might be a different
amount as on yours :-)

Michel Posseth [MCP]
 
Great, thanks both.

I tried to create a string with 2.147.483.647 characters, but around
50.000.000 characters my system can't handle it anymore. That's only 2% of
it...
 
well just as curious as i am i tried when my system couldn`t handle it
annymore


Acer 1524 WLMI Laptop ( Desktop replacement )
AMD 64 3400 +
Windows Server 2003 X64
1,2 GB of memory

running in visual studio 2003

this is still running
Dim s As New String("a", 490000000)

500000000 will raise an error ( out of memorry )

490.000.000 that is pretty much more as you :-)

now in Visula studio 2005 in x64 mode

this is still running

Dim s As New String("a", 1000000000)

however this raises the out of memory exception 1100000000


Looking at my taskmanager i saw hughe memory consumption VM size of 2 GB
physical memory of 980 MB

verry interesting as this proves to me that the maxsize of a string is
limited by

a : hardware
b : platform
C : max size of the integer data type


it is for sure that you can not ever create a string that is bigger as the
integer`s maximum size of the data type

however how the Hardware and platform relate to the maximum creatable size
is unknown to me , ,,,,,,,,,, interesting


regards

Michel Posseth



Qwert said:
Great, thanks both.

I tried to create a string with 2.147.483.647 characters, but around
50.000.000 characters my system can't handle it anymore. That's only 2% of
it...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top