Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Process Memory limit of 64-bit process

I currently have a 32-bit .Net application (on x86 Windows) which require lots of memory. Recently it started throwing System.OutOfMemoryException's.

So, I am planning to move it to a x64 platform as 64-bit process. So will this help with the out of memory exceptions. I was reading this article from MSDN Memory limits for Windows

So, my question is if I compile a 64bit .Net application, will it have IMAGE_FILE_LARGE_ADDRESS_AWARE set as default (As the article suggests)? i.e will I be able to take advantage of the 8GB user-mode virtual address space?

like image 929
SysAdmin Avatar asked Mar 08 '10 03:03

SysAdmin


People also ask

How much memory can a 64-bit process use?

Limits of processors In principle, a 64-bit microprocessor can address 16 EiB (16 × 10246 = 264 = 18,446,744,073,709,551,616 bytes, or about 18.4 exabytes) of memory.

How much memory can a process use?

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.

Do 64-bit applications use more memory?

The short answer is yes, 64-bit operating systems almost always require more RAM than corresponding 32-bit operating systems and 64-bit applications often do require a bit more RAM than corresponding 32-bit applications.

What is the maximum RAM limit for 64-bit Windows 10?

Remember that 64-bit Windows 10 Pro, Enterprise, and Education will support up to 2TB of RAM, while the 64-bit version of Windows 10 Home is limited to only 128GB.


3 Answers

The maximum memory limit for x64 processes is 8 TB, but the practical limit is far less as it depend on the amount of physical memory and the pagefile size on your system. See this post for more details on this.

The IMAGE_FILE_LARGE_ADDRESS_AWARE affect an x86 process running on a x64 OS (or a x86 OS with the /3GB directive). Your x64 application does not need to set the large address aware flag and it will be able to use all the available virtual memory on your system.

like image 82
Jeff Cyr Avatar answered Oct 13 '22 19:10

Jeff Cyr


IMAGE_FILE_LARGE_ADDRESS_AWARE is only relevant for 32 bit processes. The reason is that the address space on 32 bit Windows is split in two: 2 GB for kernel space and 2 GB for user space. To address 2 GB you need 31 bits. I.e. the pointers in a 32 bit application do not need the last bit for addressing.

Some applications may have used this extra bit for custom purposes, so if the Windows memory manager suddenly hands them a real 32 bit address they can't handle that. By enabling the IMAGE_FILE_LARGE_ADDRESS_AWARE flag the application basically tells the OS that it can handle the entire 32 bit addressable space.

If you run a IMAGE_FILE_LARGE_ADDRESS_AWARE application on 32 bit Windows you can access 3 GB. If you run the same 32 bit application on 64 bit Windows the process actually gets the entire 4 GB address space.

If you run a 64 bit application on 64 bit Windows the user address space is 8 TB (with another 8 TB set aside for kernel address space). .NET applications set to AnyCPU will automatically be 64 bit applications on x64, so you don't have to do anything to address the additional memory.

Keep in mind, however, that the CLR imposes a 2 GB limit on any single object, so while your application may use a lot of memory, you cannot create a 2 TB array for instance. More info in this question: Single objects still limited to 2 GB in size in CLR 4.0?

like image 15
Brian Rasmussen Avatar answered Oct 13 '22 19:10

Brian Rasmussen


Actually on an x64 OS if your application is compiled for AnyCPU then you don't need to do anything special. The JIT will create an x64 image at runtime or an x86 image when run on a 32 bit system.

like image 8
Josh Avatar answered Oct 13 '22 20:10

Josh