Thursday, January 19, 2012

Set 32bit Executable LARGEADDRESSAWARE Flag to True

If a 32bit executable does not have the LARGEADDRESSAWARE flag set to true, the application can't use more than 2 gigabytes. If you are on a 64bit machine with lots of memory, even if you are stuck with a 32bit process, you should ideally be able to start multiple processes each using 3+ gigabytes.

For example, the 32bit version of python is not large address aware. You might ask why use 32bit Python on a 64bit machine? Unfortunately, some third party vendors like ESRI have been slow to update to 64bit. ArcGIS Server is 64bit at 10.1, but ArcGIS Desktop remains 32 bit. We can only access their arcpy python module from 32bit Python.

Well, we can at least give our 32bit Python process a little more memory to play with:

1. Verify Visual Studio Installed
This routine was only tested using Visual Studio 2010 Professional. If you have success with Visual Studio C++ Express, please leave a comment.

2. Launch Visual Studio Command Prompt

From Start Menu: All Programs > Microsoft Visual Studio 2010 > Visual Studio Tools > Visual Studio Command Prompt (2010)
From console (cmd.exe):
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86

In either case, you should see the following message:
Setting environment for using Microsoft Visual Studio 2010 x86 tools.

3. Backup your executable

You might want to swap the old executable back if you experience unexpected issues!

4. Execute command to set the LARGEADRESSAWARE flag to true:
editbin /LARGEADDRESSAWARE "C:\Python26\ArcGIS10.0\python.exe"

If the executable is locked, copy it to a temporary directory, then overwrite original when process locking executable has finished.

5. Check that it worked
dumpbin /headers "C:\Python26\ArcGIS10.0\python.exe" | more
You should see "...Application can handle large (>2GB) addresses..."
6. Reflection Time
Ok, our hope is that we can now launch 32bit python processes that can access more than 2gb of ram. Given Murphy's Law, I'm sure we can guarantee that there will be at least some instances where this causes issues. See the third reference below for a discussion on the merits of what we just did. Personally, I like to live on the raggedy edge, but I plan on keeping the backup of the original handy to swap back in if ever needed.



  1. Thanks, this also worked for the VS Express 2013 for Desktop!

    Hopefully without consequences later on ;)

  2. I added the attribute /LARGEADDRESSAWARE to my link commands in VS2010 C++ project.

    dumpbin shows the correct results. Thanks

  3. Really great help...It worked. Thanks a lot...