GetPhysicallyInstalledSystemMemory function (sysinfoapi.h)

Retrieves the amount of RAM that is physically installed on the computer.


BOOL GetPhysicallyInstalledSystemMemory(
  [out] PULONGLONG TotalMemoryInKilobytes


[out] TotalMemoryInKilobytes

A pointer to a variable that receives the amount of physically installed RAM, in kilobytes.

Return value

If the function succeeds, it returns TRUE and sets the TotalMemoryInKilobytes parameter to a nonzero value.

If the function fails, it returns FALSE and does not modify the TotalMemoryInKilobytes parameter. To get extended error information, use the GetLastError function. Common errors are listed in the following table.

Return code Description
The TotalMemoryInKilobytes parameter is NULL.
The System Management BIOS (SMBIOS) data is malformed.


The GetPhysicallyInstalledSystemMemory function retrieves the amount of physically installed RAM from the computer's SMBIOS firmware tables. This can differ from the amount reported by the GlobalMemoryStatusEx function, which sets the ullTotalPhys member of the MEMORYSTATUSEX structure to the amount of physical memory that is available for the operating system to use. The amount of memory available to the operating system can be less than the amount of memory physically installed in the computer because the BIOS and some drivers may reserve memory as I/O regions for memory-mapped devices, making the memory unavailable to the operating system and applications.

The amount of physical memory retrieved by the GetPhysicallyInstalledSystemMemory function must be equal to or greater than the amount reported by the GlobalMemoryStatusEx function; if it is less, the SMBIOS data is malformed and the function fails with ERROR_INVALID_DATA. Malformed SMBIOS data may indicate a problem with the user's computer.


Minimum supported client Windows Vista with SP1 [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header sysinfoapi.h (include Windows.h)
Library Kernel32.lib
DLL Kernel32.dll

See also