简体   繁体   中英

How can I programmatically determine the maximum user-mode space of the (windows) OS?

I'm writing a diagnostic app which needs to log what the user has set as his user-mode space aka user-mode virtual address space aka the /3GB switch in WinXP or the increaseuserva switch in bcdedit on Vista/Win7.

Either of C++ or C++/CLI will do.

Any ideas ?

GlobalMemoryStatusEx will give you a MEMORYSTATUSEX struct with ullTotalVirtual :

The size of the user-mode portion of the virtual address space of the calling process, in bytes. This value depends on the type of process, the type of processor, and the configuration of the operating system. For example, this value is approximately 2 GB for most 32-bit processes on an x86 processor and approximately 3 GB for 32-bit processes that are large address aware running on a system with 4-gigabyte tuning enabled.

Note that you'd have to mark your EXE as LARGEADDRESSAWARE in order to see 3GB in your process .

I think there's another function that also returns this info (no - not GlobalMemoryStatus which is deprecated) along with processor info - but I can't recall it ATM.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM