All,
we have an application which always reports memory leak. How can i use GetPerformanceInfo to get an application process memory usage?
i found some code samples:
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <psapi.h>
int main (int argc, char * argv[])
{
int interval = 5000; /* default logging every 5 seconds */
time_t ltime;
struct tm *today;
MEMORYSTATUS memstat;
if (argc > 1)
interval = atoi(argv[1]);
memstat.dwLength = sizeof(MEMORYSTATUS);
do
{
GlobalMemoryStatus(&memsta
t);
time(<ime);
today = localtime(<ime);
printf("%4.4d/%2.2d/%2.2d,
%2.2d:%2.2
d:%2.2d,%d
,%d,%d,%d,
%d,%d\n",
today->tm_year + 1900, today->tm_mon + 1, today->tm_mday,
today->tm_hour, today->tm_min, today->tm_sec,
memstat.dwAvailPhys, memstat.dwAvailPageFile, memstat.dwAvailVirtual,
memstat.dwTotalPhys, memstat.dwTotalPageFile, memstat.dwTotalVirtual);
fflush(stdout);
if (interval)
Sleep (interval);
}
while (interval); /* Repeat forever, if interval is non-zero */
return 0;
}
I need to change GlobalMemoryStatus to GetProcessMemoryInfo, and change MEMORYSTATUS to PPERFORMANCE_INFORMATION.
I need values for PhysicalTotal, PhysicalAvailable PageSize
i am not VC++ person, can you help me do this?
i want a EXE file. do you know how to do that?
thanks a lot
viola
Start Free Trial