如何通过C ++检索已提交的内存 [英] How to retrieve committed memory via C++

查看:136
本文介绍了如何通过C ++检索已提交的内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在SO上,我已经找到了对该问题的几个答案,但没有一个回答我的问题. 我试图在我们的非托管C ++应用程序中查找一些内存泄漏,从阅读以下内容来看,似乎内存-提交大小"是监视内存使用情况时最好的度量标准: http://forum.sysinternals.com/virtual-private-bytes -and-working-set_topic18296.html

I've found several answers to this question here on SO, but none that answers my question. I'm trying to track down some memory leaks in our unmanaged C++ application, and from reading the following, it seems that "Memory - Commit Size" is the best metric to use when monitoring memory usage: http://forum.sysinternals.com/virtual-private-bytes-and-working-set_topic18296.html

以下是Windows Task Manager报告的各种指标的说明: http://windows .microsoft.com/en-us/windows-vista/what-do-the-task-manager-memory-columns-mean

Here's the explanation of the various metrics reported by Windows Task Manager: http://windows.microsoft.com/en-us/windows-vista/what-do-the-task-manager-memory-columns-mean

我发现以下内容描述了如何检索命名进程的工作集数据: http://msdn.microsoft.com/en-us/library/76yt3c0w.aspx

I've found the following that describes how to retrieve the Working Set data for a named process: http://msdn.microsoft.com/en-us/library/76yt3c0w.aspx

System.Diagnostics.Process[] processes =
    System.Diagnostics.Process.GetProcessesByName(theprocessName);
System.Diagnostics.Process process = processes[0];

但是,这里没有提到承诺内存:

However, this mentions nothing about Committed Memory:

任何人都可以帮忙吗? 保罗

Can anyone help? Paul

推荐答案

您似乎想使用 PROCESS_MEMORY_COUNTERS 结构.

It looks like you want to use GetProcessMemoryInfo. This populates a PROCESS_MEMORY_COUNTERS structure.

您将对该结构感兴趣的关键要素是

The key element of this structure you'll be interested in is

PagefileUsage 此过程的提交费用"值(以字节为单位).提交费用是内存管理器已为运行中的进程提交的内存总量.

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.

  • 收集进程的内存使用信息
    • Collecting Memory Usage Information For a Process
    • 这篇关于如何通过C ++检索已提交的内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆