This article explains the behavior of the
GlobalMemoryStatus function on systems with more than 2 gigabytes (GB) of RAM or 2 GB of pagefile.
Back to the top
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:
Back to the top
dwTotalPhys and dwAvailPhys
| Actual Physical Memory | /LARGEADDRESSAWARE | OS Version | Returned Value |
|---|
| < 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 |
Back to the top
dwAvailPageFile and dwTotalPageFile
| Actual Pagefile Size | /LARGEADDRESSAWARE | OS Version | Returned Value |
|---|
| < 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 |
Back to the top