使用 WinDbg 打印内存中的对象
我有一个简单的 C++ 服务,它从文件中读取文本并通过网络发送它。随着时间的推移,该服务在客户站点的内存消耗会增加。在 QA 测试中没有观察到此类行为。
我想知道是否可以在任何给定时间提取内存中的所有字符串对象。
是否可以自动化此过程,以便我在不同时间从客户那里获取转储,并找出每次内存的大小或内容并比较结果。
I have a simple C++ Service which reads text from a file and sends it over the Network. Over time the memory consumption of this service increases at customer site. No such behavior is observed in QA testing.
I would like to know if it is possible to extract all the String Objects that are in the memory at any given time.
Will it be possible to automate this process such that I take dumps from customer at different times and find out sizes or contents of the memory at each time and compare the results.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于 C++ 来说,答案是否定的(在 C# 中则不同)。在 C++ 世界中,如果您怀疑存在泄漏,则需要在“泄漏”发生之前在进程上启用用户模式堆栈跟踪(+ust 在 gflags.exe 中)。发生泄漏后,获取进程的转储并进行检查。要检查它(我假设您在此响应中使用本机 Windows 堆),您需要遍历堆结构以找出分配位置,然后检查堆栈回溯以获取最常见分配大小的样本。
例子。
For c++ the answer is no (In C# is a different story). In the c++ world, if you suspect you have a leak you would want to enable usermode stack tracing (+ust in gflags.exe) on the process before the "leak" occurs. The after the leak has occurred, get a dump of the process and examine it. To examine it (I have assumed you are using the native windows heap in this response), you will want to walk throught he heap structures to find out where the allocations are, then examine the stack backtrace for a sampling of the most common allocation size.
Example.
听起来你有内存泄漏。我只使用 Windbg 来调试托管应用程序。也许这个链接可以帮助您一点。
It sounds like you have a memory leak. I only uses windbg to debug managed applications. Maybe this Link can help you a bit.
http://msdn.microsoft.com/en- us/library/ff558947(v=vs.85).aspx 是您想做的事情的最佳选择。
http://msdn.microsoft.com/en-us/library/ff558947(v=vs.85).aspx is your best bet for what you want to do.