Can I enable Large Address Awareness dynamically at runtime?

Raymond Chen


The /LARGE­ADDRESS­AWARE flag is recorded in the header of the executable. A customer wanted to know if there was a way to select at runtime whether a process is large address aware. They were willing to accept an override in Image File Execution Options, if that’s what it took. The customer wanted to do this as part of a feature-flight, but they were concerned that third-party add-ins may behave unexpectedly when run in a large-address-aware process, and they would like a way to disable large address awareness on the fly.

Unfortunately, there is no way to change the setting at runtime, nor is there an override in Image File Execution Options. The value in the header of the executable is what the system uses to determine whether to give the process access to address space above the 2GB boundary.

But wait, all is not lost.

What the customer could do is ship two versions of the program, byte-for-byte identical except that one of them has the /LARGEADDRESSAWARE flag set, and the other has it clear.¹ They could then have their feature-flight system update the Start menu shortcut to point to the one that they want to test.

Another approach is to register the large-address-aware version in the Start menu, and have it check the feature-flight flag when it is launched. If the flag says to disable large-address-awareness, then the program launches the not-large-address-aware version with the same command line.

Yes, it’s a bit clunky, but at least it’s do-able.

¹ To reduce disk space, they could move the bulk of their code into a DLL and have the EXE be a stub that loads the DLL and then calls the Run­The­Program function in the dll.

Raymond Chen
Raymond Chen

Follow Raymond