c++ - dll加载时出错

标签 c++ visual-c++ dll memory-leaks

<分区>

我的程序试图加载一些 dll。第一次加载时不会出现问题。但它每 7 次出现一次。我猜有内存损坏。是否有工具或东西来调试 visual c++ 的内存损坏。我尝试了一些内存泄漏工具,但没有内存泄漏。

请帮忙!!!

问候, 苏雷什

最佳答案

我写了一篇博客,介绍了一些可用于查找内存损坏的步骤。真正有帮助的是 gflags 之一(#2)。

http://www.atalasoft.com/cs/blogs/loufranco/archive/2007/02/06/6-_2200_Pointers_2200_-on-Debugging-Unmanaged-Code.aspx

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/

相关文章:

c++ - 指向没有静态方法的指针静态方法

c++ - RegisterWaitForSingleObjectEx() 和几个 SetEvent()

python - linux下python读写LabView TDMS文件

c++ - 如何将 C++ dll 项目添加到 Visual Basic 引用中?

c++ - 完美转发/移动构造不适用于 std::apply 中的元组

c++ - 微软 SDK 版本

C++11 带有可变参数列表的 lambda 函数

c++ - 关于 VC++ 和 Sun Studio 中字段初始化顺序、符号比较和未使用变量的警告

c++ - 从类函数内部调用 DLL 的 extern 函数

c++ - 使用深度测试正确渲染 OpenGL 中的表面