System Information Functions (Windows)
AFAIK theres no way to get the amount of physical ram that is 'free' vs the amount that will be virtual, because any number returned would be immediately stale, the OS pages memory on an as needed basis, so there is no way of determining how much s allocated to your application right at that moment short of a kernel hack.
Then again I could be wrong, the API is pretty big.
http://msdn.microsoft.com/en-us/libr...89(VS.85).aspx
Code:
// Sample output:
// There is 51 percent of memory in use.
// There are 2029968 total Kbytes of physical memory.
// There are 987388 free Kbytes of physical memory.
// There are 3884620 total Kbytes of paging file.
// There are 2799776 free Kbytes of paging file.
// There are 2097024 total Kbytes of virtual memory.
// There are 2084876 free Kbytes of virtual memory.
// There are 0 free Kbytes of extended memory.
#include <windows.h>
#include <stdio.h>
// Use to convert bytes to KB
#define DIV 1024
// Specify the width of the field in which to print the numbers.
// The asterisk in the format specifier "%*I64d" takes an integer
// argument and uses it to pad and right justify the number.
#define WIDTH 7
void main(int argc, char *argv[])
{
MEMORYSTATUSEX statex;
statex.dwLength = sizeof (statex);
GlobalMemoryStatusEx (&statex);
printf ("There is %*ld percent of memory in use.\n",
WIDTH, statex.dwMemoryLoad);
printf ("There are %*I64d total Kbytes of physical memory.\n",
WIDTH, statex.ullTotalPhys/DIV);
printf ("There are %*I64d free Kbytes of physical memory.\n",
WIDTH, statex.ullAvailPhys/DIV);
printf ("There are %*I64d total Kbytes of paging file.\n",
WIDTH, statex.ullTotalPageFile/DIV);
printf ("There are %*I64d free Kbytes of paging file.\n",
WIDTH, statex.ullAvailPageFile/DIV);
printf ("There are %*I64d total Kbytes of virtual memory.\n",
WIDTH, statex.ullTotalVirtual/DIV);
printf ("There are %*I64d free Kbytes of virtual memory.\n",
WIDTH, statex.ullAvailVirtual/DIV);
// Show the amount of extended memory available.
printf ("There are %*I64d free Kbytes of extended memory.\n",
WIDTH, statex.ullAvailExtendedVirtual/DIV);
}