zoukankan      html  css  js  c++  java
  • PROCESS_MEMORY_COUNTERS

    typedef struct _PROCESS_MEMORY_COUNTERS {
      DWORD cb;
      DWORD PageFaultCount;
      SIZE_T PeakWorkingSetSize;           //峰值内存使用
      SIZE_T WorkingSetSize;               //内存使用
      SIZE_T QuotaPeakPagedPoolUsage;
      SIZE_T QuotaPagedPoolUsage;
      SIZE_T QuotaPeakNonPagedPoolUsage;
      SIZE_T QuotaNonPagedPoolUsage;
      SIZE_T PagefileUsage;               //虚拟内存使用
      SIZE_T PeakPagefileUsage;           //峰值虚拟内存使用
    } PROCESS_MEMORY_COUNTERS, 
    *PPROCESS_MEMORY_COUNTERS;

     以下摘自MSDN

    Members
    
    cb
    The size of the structure, in bytes.
    PageFaultCount The number of page faults.
    PeakWorkingSetSize The peak working
    set size, in bytes.
    WorkingSetSize The current working
    set size, in bytes.
    QuotaPeakPagedPoolUsage The peak paged pool usage,
    in bytes.
    QuotaPagedPoolUsage The current paged pool usage,
    in bytes.
    QuotaPeakNonPagedPoolUsage The peak nonpaged pool usage,
    in bytes.
    QuotaNonPagedPoolUsage The current nonpaged pool usage,
    in bytes.
    PagefileUsage The Commit Charge value
    in bytes for this process. Commit Charge is the total amount of memory that the memory manager has committed for a running process.
    PeakPagefileUsage The peak value
    in bytes of the Commit Charge during the lifetime of this process.

    Collecting Memory Usage Information For a Process

    #include <windows.h>
    #include <stdio.h>
    #include <psapi.h>
    
    // To ensure correct resolution of symbols, add Psapi.lib to TARGETLIBS
    // and compile with -DPSAPI_VERSION=1
    
    void PrintMemoryInfo( DWORD processID )
    {
        HANDLE hProcess;
        PROCESS_MEMORY_COUNTERS pmc;
    
        // Print the process identifier.
    
        printf( "
    Process ID: %u
    ", processID );
    
        // Print information about the memory usage of the process.
    
        hProcess = OpenProcess(  PROCESS_QUERY_INFORMATION |
                                        PROCESS_VM_READ,
                                        FALSE, processID );
        if (NULL == hProcess)
            return;
    
        if ( GetProcessMemoryInfo( hProcess, &pmc, sizeof(pmc)) )
        {
            printf( "	PageFaultCount: 0x%08X
    ", pmc.PageFaultCount );
            printf( "	PeakWorkingSetSize: 0x%08X
    ", 
                      pmc.PeakWorkingSetSize );
            printf( "	WorkingSetSize: 0x%08X
    ", pmc.WorkingSetSize );
            printf( "	QuotaPeakPagedPoolUsage: 0x%08X
    ", 
                      pmc.QuotaPeakPagedPoolUsage );
            printf( "	QuotaPagedPoolUsage: 0x%08X
    ", 
                      pmc.QuotaPagedPoolUsage );
            printf( "	QuotaPeakNonPagedPoolUsage: 0x%08X
    ", 
                      pmc.QuotaPeakNonPagedPoolUsage );
            printf( "	QuotaNonPagedPoolUsage: 0x%08X
    ", 
                      pmc.QuotaNonPagedPoolUsage );
            printf( "	PagefileUsage: 0x%08X
    ", pmc.PagefileUsage ); 
            printf( "	PeakPagefileUsage: 0x%08X
    ", 
                      pmc.PeakPagefileUsage );
        }
    
        CloseHandle( hProcess );
    }
    
    int main( void )
    {
        // Get the list of process identifiers.
    
        DWORD aProcesses[1024], cbNeeded, cProcesses;
        unsigned int i;
    
        if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
        {
            return 1;
        }
    
        // Calculate how many process identifiers were returned.
    
        cProcesses = cbNeeded / sizeof(DWORD);
    
        // Print the memory usage for each process
    
        for ( i = 0; i < cProcesses; i++ )
        {
            PrintMemoryInfo( aProcesses[i] );
        }
    
        return 0;
    }
  • 相关阅读:
    内置的包装类
    子类继承父类的哪些成员
    JAVA笔记140-使用this语句解决构造器重载相互调用问题
    Java学习
    AngularJs2
    Angular
    检测是否所有的栏位都已经填充了内容了。(可以用来判断动态放置的东西和外加的框是否一致)
    上下各有一个框,框里有元素(点击下面的元素,显示到上面的框里面去,按一定顺序排放)
    Nashorn 在JDK 8中融合Java与JavaScript之力
    2014年Facebook的开源成就
  • 原文地址:https://www.cnblogs.com/Lthis/p/4245456.html
Copyright © 2011-2022 走看看