#ifdef _WINDOWS
#include <windows.h>
#include <stdio.h>
// 프로세스 API (메모리 사용량 확인을 위해서)
#include <psapi.h>
#pragma comment(lib, "psapi.lib")
#endif
void main()
{
// Something to do
// ... 중략
#ifdef _WINDOWS
DWORD processID = GetCurrentProcessId();
HANDLE hProcess;
PROCESS_MEMORY_COUNTERS pmc;
fprintf(stderr, "Process ID: %u\n", processID);
// Print information about the memory usage of the process.
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID);
if (NULL == hProcess) exit(-1);
// GetProcessMemoryInfo 는 PSAPI library 에 구현되어 있음
if ( GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc)) )
{
fprintf(stderr, "PageFaultCount: %d\n", pmc.PageFaultCount );
fprintf(stderr, "PeakWorkingSetSize: %d\n", pmc.PeakWorkingSetSize );
fprintf(stderr, "WorkingSetSize: %d\n", pmc.WorkingSetSize );
fprintf(stderr, "QuotaPeakPagedPoolUsage: %d\n", pmc.QuotaPeakPagedPoolUsage );
fprintf(stderr, "QuotaPagedPoolUsage: %d\n", pmc.QuotaPagedPoolUsage );
fprintf(stderr, "QuotaPeakNonPagedPoolUsage: %d\n", pmc.QuotaPeakNonPagedPoolUsage );
fprintf(stderr, "QuotaNonPagedPoolUsage: %d\n", pmc.QuotaNonPagedPoolUsage );
fprintf(stderr, "PagefileUsage: %d\n", pmc.PagefileUsage );
fprintf(stderr, "PeakPagefileUsage: %d\n", pmc.PeakPagefileUsage );
}
CloseHandle( hProcess );
#endif
}