The 2 GB limit refers to a physical memory barrier for a process running on a 32-bit operating system, which can only use a maximum of 2 GB of memory. The problem mainly affects 32-bit versions of operating systems like Microsoft Windows and Linux, although some variants of the latter can overcome this barrier.
Each process on 32-bit Microsoft Windows has its own virtual address space that enables addressing up to 4 gigabytes of memory. Each process on 64-bit Windows has a virtual address space of 8 terabytes.
One bit in the register can reference an individual byte in memory, so a 32-bit system can address a maximum of 4 GB (4,294,967,296 bytes) of RAM.
Mark Russinovich published a multipart series on windows memory resources really covers this very well. You can find it here: http://blogs.technet.com/b/markrussinovich/archive/2008/07/21/3092070.aspx
He covers the reasons why the limits are what they are, as well as tests. The code for the tests are floating around in the tubes somewhere.
If you want to know about memory resources and the problems you can see from leaking the various types, it is a good read.
But, in a nutshell, 32 bit on 32 bit OS: 2 GB, unless set to large address space aware, in which case 3 GB. 32 bit on 64 bit OS: 2 GB, unless set to large address space aware, in which case 4 GB.
64 bit process: 2 GB, unless set to large address space aware, in which case it could address up to 8 TB, unless it is hosted on an Intel Itanium-based systems which is limited to 7 TB.
Microsoft states the various limits (by flavors and types) at: http://msdn.microsoft.com/en-us/library/aa366778.aspx
You could write some kind of a loop in a console app to test this.
Maybe create a string that is exactly 1MB and loop through a concatenation process to increase it's size until you get a ... Stack Overflow error.
On each iteration WriteLine the size, or number of iterations.
EDIT
I would add, since STRING is immutable (despite technically being a reference type) to use OBJECT
Edit Two
Trisped points out that a string boxed in an Object is still immutable.
Creating an Array of bytes [1024] should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With