Advertisement

01.22.2008 at 10:31PM PST, ID: 23103565
[x]
Attachment Details

How to use GetPerformanceInfo to get an application process memory usage?

Asked by viola123 in Microsoft Visual C++.Net, C Programming Language, C++ Programming Language

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(&memstat);
                time(&ltime);
                today = localtime(&ltime);
                printf("%4.4d/%2.2d/%2.2d,%2.2d:%2.2d:%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
 
Keywords: How to use GetPerformanceInfo to get …
 
Loading Advertisement...
 
[+][-]01.22.2008 at 11:12PM PST, ID: 20721346

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.22.2008 at 11:14PM PST, ID: 20721359

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.22.2008 at 11:29PM PST, ID: 20721419

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.22.2008 at 11:58PM PST, ID: 20721523

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.23.2008 at 12:08AM PST, ID: 20721552

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual C++.Net, C Programming Language, C++ Programming Language
Sign Up Now!
Solution Provided By: evilrix
Participating Experts: 4
Solution Grade: A
 
 
[+][-]01.23.2008 at 02:08PM PST, ID: 20728435

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.23.2008 at 02:53PM PST, ID: 20728803

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.23.2008 at 03:13PM PST, ID: 20728950

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]01.23.2008 at 03:16PM PST, ID: 20728981

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]01.23.2008 at 03:18PM PST, ID: 20728999

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.23.2008 at 03:20PM PST, ID: 20729020

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]01.23.2008 at 03:24PM PST, ID: 20729055

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.23.2008 at 03:26PM PST, ID: 20729062

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.24.2008 at 03:05PM PST, ID: 20738509

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.24.2008 at 03:09PM PST, ID: 20738530

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628