1

I have a 32-bit executable that I want to deploy with the LARGEADDRESSAWARE flag.

My question is:

Is it possible to put this under a toggle, e.g., via a config file or some runtime setting, so that if the config says false, the process will run without LARGEADDRESSAWARE?

Or is this something that can only be enabled/disabled by recompiling (or modifying) the exe itself?

I’d like to know if there’s any way to make this configurable on the customer’s server without rebuilding the executable.

6
  • What things are you hoping it would change after a process is already started? Like that VirtualAlloc can allocate from the high 2GiB, and file-backed mappings? Obviously the executables own code, static data, and stack space will be in the low 2GiB (or 3GiB? I forget what the thresholds are on Windows.) If you compile an exe to work with LARGEADDRESSAWARE, it might be fine to toggle the flag in the exe before running it, unless that changes interpretation of anything else, like relocation info. Commented Sep 11 at 7:23
  • Can it be done in source code somehow ? Ex : in the main method it will read some config , I need to deploy at customer site , if there are any issue with LARGEADDRESSAWARE i need to revert back . I need to achive this Commented Sep 11 at 7:56
  • If it's just a fallback "in case of issues", you could send them two builds so they can switch if one runs into problems. Commented Sep 11 at 8:05
  • Still building 32 bit apps in 2025? Commented Sep 11 at 8:49
  • we are not supposed to send two builds , is there any other way Commented Sep 11 at 8:53

1 Answer 1

10

It is not possible to do this at runtime. Microsoft's Raymond Chen answered this very question a while back in his blog (https://devblogs.microsoft.com/oldnewthing/20170906-00/?p=96955):

Can I enable Large Address Awareness dynamically at runtime?

... 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.

So no, this is hardcoded in the executable header. He then goes to suggest the two-executable (and maybe a loader/chooser) solution, similar to what's suggested by @PeterCordes.

Alternatively, since this seems to be strictly a fallback scenario in case of any issues - maybe patching the executable header in field is an option (as opposed to changing config in field)? See How to make a .NET application "large address aware"? for pointers on how to do that.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.