Chat Question: Memory Limits for 32-bit and 64-bit processes


During our recent blog chat, there were a number of topics that were asked about and I am going to expand on some of them.  The first one is the memory limits for different processes.

This really depends on a few different things.  The architecture of the process (32-bit or 64-bit) and also the architecture of the Operating System the process is running on.  For 32-bit it also depends if you use the /3GB switch or not.

So I broke this up based on these things into the table below, this is the maximum amount of memory available for the process assuming you have that much RAM and Pagefile space.

  32-bit OS 64-bit OS
32-bit process 2 GB 4 GB
32-bit process with /3GB 3 GB N/A
64-bit process N/A 16 TB

These process numbers are contingent on how much RAM and disk space you have, so if you have 4 GB of RAM and 4 GB Pagefile, the total memory of all running processes can’t be greater then 8 GB.

Note: If you let Windows manage your Pagefile size, when you hit this limit, Windows will try to grow your Pagefile as long as there is disk space available.

For the amount a .NET application will use before we can expect to see out of memory, those numbers are:

  32-bit OS 64-bit OS
32-bit process 800-1200 MB 2800 MB
32-bit process with /3GB 1800 MB N/A
64-bit process N/A 2800 MB if using a 4 GB process or more if more RAM (around 70% of RAM + Pagefile)

Keep in mind that although a .NET process can grow this large, if the process is multiple GB in size, it can become very difficult for the Garage Collector to keep up with the memory as Generation 2 will become very large.  I’ll talk about the generations more in an upcoming post.

Hopefully that will clear up how much memory each one uses.

Keep checking the RECAP- ASP.NET Blog Chat to see other topics that Tess or I write about.

kick it on DotNetKicks.com

Comments (17)

  1. You’ve been kicked (a good thing) – Trackback from DotNetKicks.com

  2. Hi Tom,

    Why would there be a 4GB memory limitation for a 64-bit process on a 64-bit version of Windows?

    The virtual address space on current AMD64-bit architectures is 16TB, 8TB system space and 8TB user space.

    Sasha

  3. Great post. Could you explain why .NET process is so much less capable in terms of memory allocation than ordinary Windows process?

  4. Sasha,

    You are correct.  I have updated the post.

    Hope that clears it up.

  5. Pawel,

    So it isn’t that .NET is able to use a lot less, but it is just a reality of how memory is used.  So the reason things cannot go up to the 2GB process space, for example, is due to fragmentation of the user process.

    You can look at my post on fragmentatin:

    http://blogs.msdn.com/tom/archive/2008/02/18/high-memory-part-5-fragmentation.aspx

    Let me know if that is enough or if you have more questions about it.

  6. Thanks to everyone that attended the chat we had today on Tess and my pages. I think it went really well

  7. Pawel Pabich says:

    Tom,  let’s assume that my app is perfect :), no pinned objects, no dynamic assembly problem, etc. Are you still saying that the app will get up to 1.2 GB? What happened to 0.8 GB that the native Windows process can allocate?

  8. Yes.  So the reason is due to the way .NET allocated memory.  If you look at a process, you will have your loaded modules and then heap memory.  .NET always grows by a segment size.  So if you don’t have that much contiguous memory available, you will get an OutOfMemoryException.  If you have something like a single page that just allocates in a loop, you can get up to 1.8 or 1.8 GB.  But in a real world application, because of where modules load, you tend to get much less.  Hope that helps clear it up.

  9. Sudhir says:

    The application needs to be modfied for using /3GB switch.

    http://www.microsoft.com/whdc/system/platform/server/PAE/PAEmem.mspx

    <snip>

    Executables that can use the 3-GB address space are required to have the bit IMAGE_FILE_LARGE_ADDRESS_AWARE set in their image header. If you are the developer of the executable, you can specify a linker flag (/LARGEADDRESSAWARE).

    To set this bit, you must use Microsoft Visual Studio Version 6.0 or later and the Editbin.exe utility, which has the ability to modify the image header (/LARGEADDRESSAWARE) flag. For more information on setting this flag, see the Microsoft Visual Studio documentation.

    </snip>

  10. mapdojo says:

    Hi Tom,

    If I have Windows x64 with 8GB RAM and I am using a 32-bit code ASP.NET SDK component that runs using WoW64, will the w3wp.exe process run as 32-bit or 64-bit ?

    I am wondering if the upper limit will be 2800MB [32-bit process limit], or 70% RAM + Pagefile [64-bit process limit].

  11. Mapdojo,

    It will depend on how you have IIS setup.  The component won’t control that.  You can check in TaskManager to see if it is w3wp.exe*32 or not.

  12. Hi, Andreas Fuchsberger here….. It is important to understand what happens CAT.NET builds its Call

  13. batmaci says:

    Hi,

    thanks for the great article but I am running asp.net application and caching some DB tables. these datatables increases size of webdev.webserver40.exe while doing local debugging and when it reaches around 1,4 gb, i am getting system out of memory exception. my asp.net app is obviously 32 bit but OS is 64. based on your article, i supposed to have 2,8 gb approx. memory available for my process. Am I wrong? if yes, how to increase it?

    thanks.

  14. Ted says:

    64bit process on x64 system, 2800 MB if using a 4 GB process, What does the 4GB process mean here?

  15. Dharmalingam Konar says:

    if you pysical and virtual less memory then u can add more memory add by additional memory or you can increase virtual memory

  16. Ted, a 4 GB process is what you get unless your machine has more then 4 GB of physical RAM.