用于查找托管 C++ 中内存损坏的工具 代码
我有一个 .NET 应用程序,它使用开源 C++ 压缩库来压缩图像。 我们通过托管 C++ 访问 C++ 库。 我在压缩过程中看到堆损坏。 对 _CrtIsValidHeapPointer 的调用发现压缩后清理时调用 free() 时出现错误。
是否有诸如 Purify 之类的工具来帮助诊断此问题以及工作时导致堆损坏的原因托管和非托管代码的组合? 我确实在调试器中捕获了异常,但最好有其他工具来帮助找到问题的解决方案。
I have a .NET application, which is using an open source C++ compression library for compressing images. We are accessing the C++ library via managed C++. I'm seeing heap corruption during compression. A call to _CrtIsValidHeapPointer is finding an error on a call to free() when cleaning up after compression.
Are there tools such as Purify to help diagnosis this problem and what is causing the heap corruption when working in a combination of managed and unmanaged code? I do have the exception caught in the debugger, but it would be nice to have other tools to help find the solution to the problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在本机代码中,如果损坏始终发生在内存中的同一位置,则可以使用
不确定这是否有帮助,但希望它能引导您走向正确的方向。
In native code, if the corruption always occurs in the same place in memory, you can use a data breakpoint to break the debugger when that memory is changed. Unfortunately, you cannot set a data breakpoint in the managed C++ environment, presumably because the GC could move the object in memory.
Not sure if this helps, but hopefully it leads you off in the right direction.
在 *nix 上,有一个名为 Valgrind 我用它来处理内存问题,比如内存泄漏和内存损坏。
On *nix, there's a tool called Valgrind that I use for dealing with memory issues, like memory leaks and memory corruption.
Rational Purify for Windows 支持 .NET,所以我想这可以使用。
Rational Purify for Windows supports .NET, so I guess that could be used.