如何以编程方式获取应用程序的内存使用情况

时间:2017-04-06 15:02:19

标签: c++ windows memory memory-management memory-leaks

我希望以编程方式从内部获取应用程序(Windows,Win7,x64)的内存使用情况。我尝试使用API​​ GetProcessMemoryInfo(),但我不确定返回的值。

我想得到的是:

  • 应用程序使用的总内存( RAM +页面文件

  • 应用程序使用的总物理内存(仅限RAM )。

我的目标是通过在我的应用程序中执行重复性任务并监视/记录已用内存的演变来跟踪内存泄漏。

注意:目前我使用PROCESS_MEMORY_COUNTERS::PageFileUsage作为总内存,PROCESS_MEMORY_COUNTERS::WorkingSetSize作为物理(RAM)内存。我认为这不是获得我想要的正确方法。

1 个答案:

答案 0 :(得分:0)

I refered to this question and follow the recommendations. From PROCESS_MEMORY_COUNTERS_EX::PrivateUsage I got the same values as from PROCESS_MEMORY_COUNTERS::PageFileUsage.

I assume the solution I used and described in my question is the right one.

相关问题