Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a (32-bit) .NET application to use 3 GB RAM?

I am creating a .NET application (C#) that needs to use a lot of RAM. I recently knew that on 32-bit versions of Windows XP I can only use 2 GB, unless I use the /3Gb switch, and set the IMAGE_FILE_LARGE_ADDRESS_AWARE flag in the executable header. But since I'm developing a .NET application, I guess I cannot modify the executable directly, can I? So, what should I do to allow my application to utilize the 3 GB?

like image 390
Hosam Aly Avatar asked Jan 21 '09 08:01

Hosam Aly


People also ask

How much RAM can a 32-bit app 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.

Can 32-bit applications use more than 4GB of RAM?

A 32-bit application can allocate more than 4GB of memory, and you don't need 64-bit Windows to do it. Commenter Herb wondered how a 32-bit program running on 64-bit Windows can allocate more than 4GB of memory. Easy: The same way it allocates more than 4GB of memory on 32-bit Windows!

Why is 4GB limited 32-bit?

Every byte of RAM requires its own address, and the processor limits the length of those addresses. A 32-bit processor uses addresses that are 32 bits long. There are only 4,294,967,296, or 4GB, possible 32-bit addresses. There are workarounds to these limitations, but they don't really apply to most PCs.

How much memory can a 64-bit application use?

The theoretical memory limit that a 64-bit computer can address is about 16 exabytes (16 billion gigabytes), Windows XP x64 is currently limited to 128 GB of physical memory and 8 TB of virtual memory. In the future this limit will be increased, basically because hardware capabilities will improve.


1 Answers

An .NET exe is still a standard PE file; so you could try using editbin /LARGEADDRESSAWARE to set the flag, but note that this won't work if you are using something like ClickOnce (since that maintains a cryptographic hash of the files).

However, note that you'll still have the same .NET limits in terms of the maximum size of a single object/array. For huge amounts of memory, x64 is a better idea.

like image 56
Marc Gravell Avatar answered Sep 21 '22 12:09

Marc Gravell