There is another way to watch memory usage in program with win32 api.
MEMORYSTATUS ms;
ms.dwLength = sizeof(ms);
GlobalMemoryStatus(&ms);
const int nBufSize = 512;
TCHAR chBuf[nBufSize];
::ZeroMemory(chBuf,nBufSize);
// Process-specific info (for calling process)
wsprintf(chBuf,_T("TotalVirtual: %ld\n"), ms.dwTotalVirtual);
OutputDebugString(chBuf);
wsprintf(chBuf,_T("AvailVirtual: %ld\n"), ms.dwAvailVirtual);
OutputDebugString(chBuf);
// Process virtual memory usage (reserved + commit)
wsprintf(chBuf,_T("UsageVirtual: %ld\n"), ms.dwTotalVirtual - ms.dwAvailVirtual);
OutputDebugString(chBuf);
// System info
wsprintf(chBuf,_T("MemoryLoad: %ld\n"), ms.dwMemoryLoad);
OutputDebugString(chBuf);
wsprintf(chBuf,_T("TotalPhys: %ld\n"), ms.dwTotalPhys);
OutputDebugString(chBuf);
wsprintf(chBuf,_T("AvailPhys: %ld\n"), ms.dwAvailPhys);
OutputDebugString(chBuf);
// System usage
wsprintf(chBuf,_T("UsagePhys: %ld\n"), ms.dwTotalPhys - ms.dwAvailPhys);
OutputDebugString(chBuf);
// Unused/unsupported
wsprintf(chBuf,_T("TotalPageFile: %lu\n"), ms.dwTotalPageFile);
OutputDebugString(chBuf);
wsprintf(chBuf,_T("AvailPageFile: %lu\n"), ms.dwAvailPageFile);
OutputDebugString(chBuf);
ms.dwLength = sizeof(ms);
GlobalMemoryStatus(&ms);
const int nBufSize = 512;
TCHAR chBuf[nBufSize];
::ZeroMemory(chBuf,nBufSize);
// Process-specific info (for calling process)
wsprintf(chBuf,_T("TotalVirtual: %ld\n"), ms.dwTotalVirtual);
OutputDebugString(chBuf);
wsprintf(chBuf,_T("AvailVirtual: %ld\n"), ms.dwAvailVirtual);
OutputDebugString(chBuf);
// Process virtual memory usage (reserved + commit)
wsprintf(chBuf,_T("UsageVirtual: %ld\n"), ms.dwTotalVirtual - ms.dwAvailVirtual);
OutputDebugString(chBuf);
// System info
wsprintf(chBuf,_T("MemoryLoad: %ld\n"), ms.dwMemoryLoad);
OutputDebugString(chBuf);
wsprintf(chBuf,_T("TotalPhys: %ld\n"), ms.dwTotalPhys);
OutputDebugString(chBuf);
wsprintf(chBuf,_T("AvailPhys: %ld\n"), ms.dwAvailPhys);
OutputDebugString(chBuf);
// System usage
wsprintf(chBuf,_T("UsagePhys: %ld\n"), ms.dwTotalPhys - ms.dwAvailPhys);
OutputDebugString(chBuf);
// Unused/unsupported
wsprintf(chBuf,_T("TotalPageFile: %lu\n"), ms.dwTotalPageFile);
OutputDebugString(chBuf);
wsprintf(chBuf,_T("AvailPageFile: %lu\n"), ms.dwAvailPageFile);
OutputDebugString(chBuf);
沒有留言:
張貼留言