Application with LARGEADDRESSAWARE flag set getting less virtual memory

雨燕双飞 提交于 2019-12-08 15:41:21

问题


I have a 32 bit application consisting one exe and multiple dlls. The exe has been built with /LARGEADDRESSAWARE flag set. So I expect on a 64 bit OS I should get 4 GB of user address space. But on some 64 bit Win 7 systems I am getting only 2 GB of user address space. The physical memory is 8 GB if that matters. What could be reason for this behavior?


回答1:


After browsing through MSDN, I found the following:

On http://msdn.microsoft.com/en-us/library/windows/desktop/aa366770(v=vs.85).aspx (the page for MEMORYSTATUSEX which is used by GlobalMemoryStatusEx (http://msdn.microsoft.com/en-us/library/windows/desktop/aa366589(v=vs.85).aspx) ) the description for ullTotalVirtual is:

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.

The 4GB tuning page is: http://msdn.microsoft.com/en-us/library/windows/desktop/bb613473(v=vs.85).aspx and it says something like:

On 64-bit editions of Windows, 32-bit applications marked with the IMAGE_FILE_LARGE_ADDRESS_AWARE flag have 4 GB of address space available.

Itanium editions of Windows Server 2003: Prior to SP1, 32-bit processes have only 2 GB of address space available.

Also, the memory limits page (http://msdn.microsoft.com/en-us/library/aa366778.aspx#memory_limits) can come handy if you want to determine the total memory your system supports.

However the real useful information comes from Mark Russinowich's blog: http://blogs.technet.com/b/markrussinovich/archive/2008/07/21/3092070.aspx

While 4GB is the licensed limit for 32-bit client SKUs, the effective limit is actually lower and dependent on the system's chipset and connected devices. The reason is that the physical address map includes not only RAM, but device memory as well, and x86 and x64 systems map all device memory below the 4GB address boundary to remain compatible with 32-bit operating systems that don't know how to handle addresses larger than 4GB.

So the conclusion is that yes, this might depend on the configuration of the system. Maybe you can complete your question with a table, with the amount of the memory you get on each system and some important system configuration settings, and we might discover a pattern in this case.




回答2:


The problem is that an Application has a whole has to be large Adress aware - so that pointers are to be treated as unsigned.

If however on "some" system some of your used DLL is not large adressaware this renders your whole program not large address aware.

http://blogs.msdn.com/b/oldnewthing/archive/2010/09/22/10065933.aspx



来源:https://stackoverflow.com/questions/25424236/application-with-largeaddressaware-flag-set-getting-less-virtual-memory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!