INFO: GlobalMemoryStatus() Function Behavior on Systems with More than 2 GB RAM

This article was previously published under Q274558
This article has been archived. It is offered "as is" and will no longer be updated.
This article explains the behavior of the GlobalMemoryStatus function on systems with more than 2 gigabytes (GB) of RAM or 2 GB of pagefile.
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

Actual Physical Memory/LARGEADDRESSAWAREOS VersionReturned Value
< 2 GBNoAllCorrect
< 4 GBYesAllCorrect
> or = 2 GB, < 4 GBNoAll2 GB
> or = 4 GBN/AWindows NT 4.0 SP3 or earlierActual size modulo 4 GB
> or = 4 GBN/AWindows NT 4.0 SP4 or later-1

dwAvailPageFile and dwTotalPageFile

Actual Pagefile Size/LARGEADDRESSAWAREOS VersionReturned Value
< 4 GBN/AAllCorrect
> or = 4 GBN/AWindows NT 4.0Actual size modulo 4 GB
> or = 4 GBN/AWindows 2000 and Windows XP-1

Article ID: 274558 - Last Review: 02/27/2014 21:07:06 - Revision: 4.1

Microsoft Win32 Application Programming Interface

  • kbnosurvey kbarchive kbinfo kbapi kbmemory kbkernbase KB274558