When no LARGEADDRESSAWARE switch is given in a 32bit executable, 2GB of memory (give or take) is available the the process to use. When the switch LARGEADDRESSAWARE is present in the PE flags of the executable this limit can be (correct me if I am wrong):
- 2GB if a 32 bit Windows was not started with the /3GB switch
- 3GB if a 32 bit Windows was started with the /3GB switch
- almost up to 4GB if the process runs under a Windows 64 bit OS as a 32 bit process.
My question is: how can one determine this memory limit (with and/or without the LARGEADDRESSAWARE flag)? And as a sidenote: is the enumeration of possibilities above correct?
Note: I am not interested in the amount of memory the process is using, also not the limit due to external effects, just the maximum amount of memory I can allocate in the ideal case.
I think the best approach is to call
GetSystemInfoand work out what you need fromlpMinimumApplicationAddressandlpMaximumApplicationAddress. You can simply subtract the former from the latter to obtain the total available addressable memory space.Your three bullet points of the various possibilities are correct.