본문 바로가기
C & C++/C & C++

메모리 관련 정보 얻어오기

by izen8 2012. 8. 13.
반응형

[메모리 관련 정보 얻어오기]


GlobalMemoryStatus()함수 MSDN 참고 예제

#include <windows.h>

#define DIV 1024

char *divisor = "K";

void
main(int argc, char *argv[])
{
MEMORYSTATUS stat;

GlobalMemoryStatus (&stat);

printf ("The MEMORYSTATUS structure is %ld bytes long.\n",
stat.dwLength);
printf ("It should be %d.\n", sizeof (stat));
printf ("There is %ld percent of memory in use.\n",
stat.dwMemoryLoad);
printf ("There are %ld total %sbytes of physical memory.\n",
stat.dwTotalPhys/DIV, divisor);
printf ("There are %ld free %sbytes of physical memory.\n",
stat.dwAvailPhys/DIV, divisor);
printf ("There are %ld total %sbytes of paging file.\n",
stat.dwTotalPageFile/DIV, divisor);
printf ("There are %ld free %sbytes of paging file.\n",
stat.dwAvailPageFile/DIV, divisor);
printf ("There are %ld total %sbytes of virtual memory.\n",
stat.dwTotalVirtual/DIV, divisor);
printf ("There are %ld free %sbytes of virtual memory.\n",
stat.dwAvailVirtual/DIV, divisor);
}

 

반응형

댓글