Reputation: 5273
I am looking for method that return available RAM and for this moment I have found only this answer
https://stackoverflow.com/a/2513561/5709159
#include <windows.h>
unsigned long long getTotalSystemMemory()
{
MEMORYSTATUSEX status;
status.dwLength = sizeof(status);
GlobalMemoryStatusEx(&status);
return status.ullTotalPhys;
}
But this method return Total memory. So, I need to find out how to get RAM that currently in usage or method than directly return available RAM.
How to do it?
EDIT
I need to know amount of available RAM in order to present it on my statistic form. I have a field Available RAM :
Upvotes: 1
Views: 476
Reputation: 51894
You can use the same call to GlobalMemoryStatusEx()
and examine the .ullAvailPhys
field of the MEMORYSTATUSEX structure to get the amount of available physical memory. The difference between this and the .ullTotalPhys
value will be how much physical memory is in use.
Upvotes: 4