September 6th, 2017

Can I enable Large Address Awareness dynamically at runtime?

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.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.