如何以编程方式获取 vmmap 中显示的信息? [英] How do I get the information shown in vmmap programatically?

查看:25
本文介绍了如何以编程方式获取 vmmap 中显示的信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何看过 Mark Russovich 演讲揭秘内存管理之谜"的人都知道,vmmap 工具可以向您展示与您的进程限制(在 vanilla 32 位 Windows 上为 2GB)相关的内容,而其他工具似乎不知道这些内容.

As anyone who has watched the Mark Russovich talk "Mysteries of Memory Management Revealed" knows, the vmmap tool can show you things that count against your process limit (2GB on vanilla 32 bit windows) that few other tools seem to know about.

我希望能够以编程方式监控我的真实总内存大小(与进程限制密切相关的那个),这样我至少可以在接近进程限制时记录正在发生的事情.是否有任何关于 vmmap 如何做到这一点的公开信息?

I would like to be able to programmatically monitor my real total memory size (the one that's germane to the process limit) so I can at least log what's going on when I approach the process limit. Is there any information publicly available on how vmmap does this?

...另外,为什么这些信息很难获得??

... Also, why is this information so darn hard to get??

我所知道的事情 (AFAIK) 并不能完全为您提供全貌:

Things I know about that (AFAIK) don't quite give you the full picture:

  • ::GetProcessMemoryInfo 看起来只返回有关私有内存使用情况的信息
  • System.Diagnostics.Process.VirtualMemorySize64 返回一个相当大的数字,它仍然与 vmmap 显示的总数不完全匹配——实际上它与 vmmap 中显示的任何内容都不匹配:(

推荐答案

我使用了 Dependency Walker 来查看vmmap.exeKernel32.dll导入Windows API函数,发现以下可能相关的函数:

I used the Dependency Walker to look at which Windows API functions were imported from Kernel32.dll by vmmap.exe and found the following functions which are probably relevant:

VirtualAlloc
VirtualAllocEx
VirtualFree
VirtualProtectEx
VirtualQueryEx

看看那些,看看你是否能找到 vmmap 正在做什么.当然,任何其他动态调用的 API(即通过 LoadLibrary)都不会出现在依赖项walker 中.在处理并行加载的 DLL 时,它也被破坏了.

Take a look at those and see if you can find what vmmap is doing. Of course any other API calls made dynamically (i.e. via LoadLibrary) would not show up in the dependency walker. It's also known to be broke when dealing with side-bys-de loaded DLLs.

这篇关于如何以编程方式获取 vmmap 中显示的信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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