<分区>
我的程序试图加载一些 dll。第一次加载时不会出现问题。但它每 7 次出现一次。我猜有内存损坏。是否有工具或东西来调试 visual c++ 的内存损坏。我尝试了一些内存泄漏工具,但没有内存泄漏。
请帮忙!!!
问候, 苏雷什
<分区>
我的程序试图加载一些 dll。第一次加载时不会出现问题。但它每 7 次出现一次。我猜有内存损坏。是否有工具或东西来调试 visual c++ 的内存损坏。我尝试了一些内存泄漏工具,但没有内存泄漏。
请帮忙!!!
问候, 苏雷什
最佳答案
我写了一篇博客,介绍了一些可用于查找内存损坏的步骤。真正有帮助的是 gflags 之一(#2)。
Use Debugging Tools for Windows: If you don't have this, go get it now. For some serious debugging, you get windbg, which I will write a blog about soon. But, the utility I use most is GFLAGS. One of the most useful features it has is the ability to make every heap allocation on its own page (+hpa). This means that you can detect a memory out of bounds error at the point of the initial dereference, not later when you end up scribbling on something important.
This option makes your process use much more memory and is noticeably slower. I recommend running your entire unit test suite in the debugger after running this line from the command prompt (if you are using the NUnit gui test runner).
gflags -i nunit-gui.exe +hpa
Replace nunit-gui.exe with the name of your test runner .exe. (remember to turn it off when you are done with -hpa). More on GFLAGS.
WinDBG is essential for tracking down unmanaged memory leaks. You could also check out AutomatedQA's tools for this which are orders of magnitude easier to use -- I still think it's worth learning WinDBG though.
关于c++ - dll加载时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4054804/