O'Reilly logo

Windows® via C/C++, Fifth Edition by Christophe Nasarre, Jeffrey Richter

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Virtual Memory Status

A Windows function called GlobalMemoryStatus retrieves dynamic information about the current state of memory:

VOID GlobalMemoryStatus(LPMEMORYSTATUS pmst);

I think that this function is poorly named–GlobalMemoryStatus implies that the function is somehow related to the global heaps in 16-bit Windows. I think that GlobalMemoryStatus should have been called something like VirtualMemoryStatus instead.

When you call GlobalMemoryStatus, you must pass the address of a MEMORYSTATUS structure. The MEMORYSTATUS data structure is shown here:

typedef struct _MEMORYSTATUS { DWORD dwLength; DWORD dwMemoryLoad; SIZE_T dwTotalPhys; SIZE_T dwAvailPhys; SIZE_T dwTotalPageFile; SIZE_T dwAvailPageFile; SIZE_T dwTotalVirtual; SIZE_T dwAvailVirtual; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required