INFO: GlobalMemoryStatus() Function Behavior on Systems with More than 2 GB RAM (274558)
The information in this article applies to:
- Microsoft Win32 Application Programming Interface (API), when used with:
- the operating system: Microsoft Windows NT 4.0
- the operating system: Microsoft Windows 2000
- the operating system: Microsoft Windows XP
This article was previously published under Q274558 SUMMARY
This article explains the behavior of the GlobalMemoryStatus function on systems with more than 2 gigabytes (GB) of RAM or 2 GB of pagefile.
MORE INFORMATION
On Intel x86-based computers with more than 2 GB and less than 4 GB of RAM, the GlobalMemoryStatus function always returns "2 GB" in the dwTotalPhys member of the MEMORYSTATUS structure. Similarly, if the total available RAM is between 2 and 4 GB, the dwAvailPhys member of the MEMORYSTATUS structure will be rounded down to 2 GB. If the executable is linked by using the /LARGEADDRESSAWARE linker option, the GlobalMemoryStatus function returns the correct amount of physical memory in both members.
On Microsoft Windows NT 4.0 with any Service Pack (SP) installed, the GlobalMemoryStatus function will get the correct pagefile for the dwAvailPageFile and the dwTotalPageFile members on systems in which the pagefile is less than 4 GB. If the pagefile is more than 4 GB, the dwAvailPageFile and dwTotalPageFile members will be modulo 4 GB on all Windows NT-based systems. This behavior is irrespective of the /LARGEADDRESSAWARE linker option for the executable. However, the physical memory members depend on the /LARGEADDRESSAWARE linker option.
On computers with more than 4 GB of RAM or pagefile, the GlobalMemoryStatus function can return incorrect information. Early service pack versions of Windows NT 4.0 report a value that is the real amount of RAM or pagefile, modulo 4 GB. Because a DWORD is used for dwTotalPhys, dwAvailPhys, dwTotalPageFile, and dwAvailPageFile, the values will be correct only up to 2^32, which is 4 GB. Anything more than that will have a modulo 4 GB value, because it will overflow the value that can be stored in a DWORD data type. Windows 2000 will report a value of -1 (0xFFFFFFFF) to indicate an overflow over 4 GB of RAM or Pagefile.sys. Windows NT 4.0 with SP4, SP5, or SP6/6a will report a value of -1 (0xFFFFFFFF) to indicate an overflow over 4 GB RAM. On Microsoft Windows 2000 and Microsoft Windows XP, applications should use the GlobalMemoryStatusEx function instead.
The following tables summarize this function:
dwTotalPhys and dwAvailPhys|
< 2 GB | No | All | Correct | < 4 GB | Yes | All | Correct | > or = 2 GB, < 4 GB | No | All | 2 GB | > or = 4 GB | N/A | Windows NT 4.0 SP3 or earlier | Actual size modulo 4 GB | > or = 4 GB | N/A | Windows NT 4.0 SP4 or later | -1 |
dwAvailPageFile and dwTotalPageFile|
< 4 GB | N/A | All | Correct | > or = 4 GB | N/A | Windows NT 4.0 | Actual size modulo 4 GB | > or = 4 GB | N/A | Windows 2000 and Windows XP | -1 |
Modification Type: | Major | Last Reviewed: | 12/18/2003 |
---|
Keywords: | kbAPI kbinfo kbKernBase kbMemory KB274558 |
---|
|