The maximum amount of memory any single process on Windows can address

54,826

Solution 1

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

Solution 2

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.

Share:
54,826
Admin
Author by

Admin

Updated on September 14, 2021

Comments

  • Admin
    Admin over 2 years

    Memory Limits for Windows Releases answers what is the maximum amount of memory any single process on Windows can address:

    On 32-bit versions of Windows, a single process can map and address no more than 3GB of virtual memory at time. In 64-bit versions of Windows, a 32-bit process can map and address no more than 4GB of virtual memory at a time.

    For 64-bit processes, the amount is difficult to calculate as there are numerous overlapping limits that could apply depending on all kinds of factors. It's typically around 7TB.

    My question: How to verify the values such as "3GB", "4GB" etc.?

    Can a C# program be written to prove it? Is there a method for it?