Increase max available memory for 32 bits processes

Sometimes, you are face of strange situation for which you must take some decisions to decrease politics pressure, and to increase available time to solve the problem...

Increasing available memory of a 32bit app could appear to be one of them, and in case of Memory Leaks, you should look for, and correct your code.
Tools like JetBrains DotMemory, Red gate Ants, or the one included in Visual Studio (doc here) could help you...

But, to give you a bit of fresh air, you can increase max memory available for your App...

32 bits CLR processes are theoricaly limited to 2Gb of virtual memory on a 64bits OS. In reality, OutOfMemory can occurs from 800Mb.

To increase this limitation to more or less 3Gb, you need to use EditBin.exe. This is provided by Visual Studio installs or Windows SDK.
This tool will set a flag in the header of the exe, then Windows will let this process use more memory...

To use it :

  • Make a copy of the original exe to patch...
  • Call :
    "$PathToEditBin\editbin.exe" /LARGEADDRESSAWARE "$PathToMyExe\MyExe.exe"

To check if exe is patched, call dumpbin like this :

> dumpbin /headers "$PathToMyExe\MyExe.exe" | more

Dump of file MyExe.exe

PE signature found
File Type: EXECUTABLE IMAGE
FILE HEADER VALUES
             14C machine (x86)
               4 number of sections
        4BA1FAB3 time date stamp Thu Mar 18 12:04:35 2010
               0 file pointer to symbol table
               0 number of symbols
              E0 size of optional header
             122 characteristics
                   Executable
                   Application can handle large (>2GB) addresses
                   32 bit word machine
Line Application can handle large (>2GB) addresses give you the light !

More informations :

https://support.microsoft.com/en-us/help/2020006/how-to-troubleshoot-out-of-memory-issues-system-outofmemoryexception-i
https://docs.microsoft.com/en-us/cpp/build/reference/editbin-reference?view=vs-2019

Enjoy

Comments are closed