Microsoft KB Archive/274558

{|
 * width="100%"|

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

 * }

Q274558

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API), used with:
 * the operating system: Microsoft Windows 2000
 * the operating system: Microsoft Windows NT 4.0

-

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 &quot;2 GB&quot; 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 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 Windows 2000, applications should use the GlobalMemoryStatusEx function instead.

The following tables summarize this function:

dwAvailPageFile and dwTotalPageFile
Additional query words:

Keywords : kbAPI kbKernBase kbMemory kbSDKWin32 kbDSupport kbGrpDSKernBase

Issue type : kbinfo

Technology : kbAudDeveloper kbWin32API