CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2008
    Posts
    15

    Please check this program...

    Hi All,

    > I have written a program that creates a child process and calculates the child process memory usage

    > Please tell me what is an alternative for "Sleep(20000);" ( i need to wait till the child process finishes its execution)

    > and i have no idea about the output, on my console (i,e output consists of numbers)


    my Output:****************************


    PagefileUsage : 0

    PeakPagefileUsage : 3420160

    cb : 40

    PageFaultCount : 2665

    PeakWorkingSetSize : 8192000

    WorkingSetSize : 36864

    Done.



    my Code:*****************************

    int main()
    {
    STARTUPINFO si;
    PROCESS_INFORMATION pi;


    GetStartupInfo(&si);


    CreateProcess ("E:\\MemoryUsageProgram.exe", // Name of app to launch
    NULL,
    NULL,
    NULL,
    FALSE,
    0,
    NULL,
    NULL,
    &si,
    &pi);


    Sleep(20000);



    PROCESS_MEMORY_COUNTERS PProcessMemoryCounters;

    GetProcessMemoryInfo (pi.hProcess,
    &PProcessMemoryCounters,
    sizeof(PProcessMemoryCounters));


    cout<<"\n"
    <<"PagefileUsage: "<<PProcessMemoryCounters.PagefileUsage<<endl
    <<"PeakPagefileUsage: "<<PProcessMemoryCounters.PeakPagefileUsage<<endl
    <<"cb: "<<PProcessMemoryCounters.cb<<endl
    <<"PageFaultCount: "<<PProcessMemoryCounters.PageFaultCount<<endl
    <<"PeakWorkingSetSize: "<<PProcessMemoryCounters.PeakWorkingSetSize<<endl
    <<"WorkingSetSize: "<<PProcessMemoryCounters.WorkingSetSize<<endl;


    cout<<"\nDone.\n";

    return 0;
    }


    >Please suggest me alternative instruction for "Sleep(20000);" (to wait till child process is finished)

    > and about the output, currently I'm assuming the output (numerical values) are in BYTES.

    THANK YOU IN ADVANCE...

    John.

  2. #2
    Join Date
    May 2006
    Location
    Dresden, Germany
    Posts
    458

    Re: Please check this program...

    Here is an example code. http://www.codeguru.com/cpp/misc/misc/article.php/c383/

    With regards
    Programartist

  3. #3
    Join Date
    May 2006
    Location
    Norway
    Posts
    1,709

  4. #4
    Join Date
    Nov 2008
    Posts
    15

    Re: Please check this program...

    > thanks!! for the instruction alternative to "Sleep" , it helped me a lot...

    >could u please tell me about the output .... is it in BYTES [especially for PeakPagefileUsage ( PProcessMemoryCounters.PeakPagefileUsage ) for the code above]...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured