tags:

views:

312

answers:

3

I know that a 32-bit OS cannot see more than 4 GB of RAM.
So if I were to install, say, 6 GB of RAM on a machine running 32-bit OS, is there any way to identify that?
I know one way to get the installed RAM is through WMI class: win32_physicalmemory.Capacity
But I don't know if it'll show the correct installed ram size rather than supported.
I don't have the setup to test this scenario, but if some one already knows this, please confirm.
Else, please let me know if there's some other way of doing the same. I'm asking this for any windows 32-bit OS.

Thanks in advance.
Samrat Patil.

+1  A: 

WMI reports all memory sizes as uint64 as can be seen in the documentation for Win32_OperatingSystem.

Joey
+1  A: 

There is quite nice function GlobalMemoryStatusEx that should solve your problem. It gives back

typedef struct _MEMORYSTATUSEX {
  DWORD     dwLength;
  DWORD     dwMemoryLoad;
  DWORDLONG ullTotalPhys;
  DWORDLONG ullAvailPhys;
  DWORDLONG ullTotalPageFile;
  DWORDLONG ullAvailPageFile;
  DWORDLONG ullTotalVirtual;
  DWORDLONG ullAvailVirtual;
  DWORDLONG ullAvailExtendedVirtual;
}MEMORYSTATUSEX, *LPMEMORYSTATUSEX;

I think you are looking for ullTotalPhys. All values are in bytes.

Michal Sznajder
+4  A: 

32bit operating systems CAN see more than 4GB of memory with PAE-enabled CPUs. It's just that the 32bit address space is limited to 4GB. But as the application has only access to its own virtual address space, it can't tell if some memory it allocated lays in 1st or 5th gigabyte of memory.

On windows, you can use the GetPhysicallyInstalledSystemMemory function:

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.

Read more: http://www.geoffchappell.com/viewer.htm?doc=notes/windows/license/memory.htm

Kasprzol