如何得到指定进程的当前内存使用量?

解决方案 »

  1.   

    使用GetProcessMemoryInfoThe GetProcessMemoryInfo function retrieves information about the memory usage of the specified process in the PROCESS_MEMORY_COUNTERS structure. 
    BOOL GetProcessMemoryInfo(
      HANDLE Process,                          // handle to process
      PPROCESS_MEMORY_COUNTERS ppsmemCounters, // buffer
      DWORD cb                                 // size of buffer
    );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;
    typedef PROCESS_MEMORY_COUNTERS *PPROCESS_MEMORY_COUNTERS;
      

  2.   

    GetProcessMemoryInfo可以获得进程的内存信息
      

  3.   

    对不起,怪我没说清楚.我想得到的是windows2000中任务管理器中进程的内存使用和虚拟内存大小这两项.你的那个函数我也用过,但得不到这两项.
      

  4.   

    To 楼主:
    任务管理器中的内存使用即此结构中的WorkingSetSize
    虚拟内存大小即PagefileUsage.