调试 Windows 资源管理器扩展中的内存泄漏
大家好,
我是一个相当大的 C# Windows 资源管理器扩展的开发人员。正如您可以想象的那样,涉及很多 P/Invoke,不幸的是,我已经确认它在某处泄漏了非托管内存。然而,我对如何找到泄漏点一无所知。我尝试遵循这个有用的指南,它说使用WinDBG。但是,当我尝试使用 !heap 时,它不会让我这么做,因为我没有 explorer.exe 的 .PDB 文件(显然,公共符号文件还不够)。
帮助?
Greetings all,
I'm the developer of a rather large C# Windows Explorer extension. As you can imagine, there is a lot of P/Invoke involved, and unfortunately, I've confirmed that it's leaking unmanaged memory somewhere. However, I'm coming up empty as to how to find the leak. I tried following this helpful guide, which says to use WinDBG. But, when I try to use !heap, it won't let me because I don't have the .PDB files for explorer.exe (and the public symbol files aren't sufficient, apparently).
Help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经使用过很多次UMDH,效果非常好。您提到的描述 WinDbg 的指南使用与 UMDH 相同的方法,基于调试堆记录所有分配的堆栈跟踪的能力。唯一的区别是 UMDH 是自动化的——您只需从命令行运行 umdh,它就会创建所有当前分配的快照。通常,您会重复快照两次或多次,然后计算两个快照之间的“增量”(也使用 umdh.exe)。 “增量”文件上的信息为您提供快照之间发生的所有新分配,并按分配大小排序。
UMDH 也需要符号。您至少需要 ntdll.dll 的符号(堆实现位于此处)。 http://msdl.microsoft.com/download/symbols 中的公共符号上提供的公共符号将工作正常。
确保您使用的 umdh.exe 位数正确。 Explorer.exe 在 64 位操作系统上是 64 位的,因此如果您的操作系统是 64 位,您需要使用 64 位 umdh.exe——即下载适当位数的 Windows 调试工具。
I've used many time UMDH with very good results. The guide you mentioned describing WinDbg uses the same method as UMDH, based on ability of debug heap to record stack traces for all allocations. The only difference is that UMDH does it automated -- you simply run umdh from command line and it creates snapshot of all current allocations. Normally you to repeate the snapshots two or more times, then you calculate 'delta' between two snapshots (also using umdh.exe). The information on the 'delta' file gives you all new allocations that happen between your snapshots, sorted by the allocation size.
UMDH also needs symbols. You will need at least symbols for ntdll.dll (heap implementation lives there). Public symbols available on public symbols from http://msdl.microsoft.com/download/symbols will work fine.
Make sure you are using correct bitness of the umdh.exe. Explorer.exe is 64 bit on 64 bit OS, so if your OS is 64 bit you need to use 64 bit umdh.exe -- i.e. download appropriate bitness of Windows debugging tools.