在VS C++ 6.0中,哪些调试工具适合查找内存泄漏的位置

In VS C++ 6.0, what debug tools are good to find where memory is leaking?

本文关键字:查找 内存 泄漏 位置 调试工具 C++ VS      更新时间:2023-10-16

我的程序最终消耗了所有内存并崩溃...浏览代码,我找不到任何突出的东西可以做到这一点。

你能修改代码以使用 mallocfree 的调试版本吗?如果是,请检查_malloc_dbg和_free_dbg。

(您可以基于这些函数编写自己的newdelete运算符。

我记得VS 6.0没有_realloc_dbg.

#ifdef _DEBUG
#define _CRTDBG_MAP_ALLOC 1
#include <Crtdbg.h>
#define malloc(size) _malloc_dbg(size,_CLIENT_BLOCK,__FILE__,__LINE__)
#define free(addr) _free_dbg(addr,_CLIENT_BLOCK)
#endif

你可以试试 BoundsChecker(现在是 DevPartner): http://www.microfocus.com/products/micro-focus-developer/devpartner/index.aspx

您将能够在代码中看到内存泄漏、接口泄漏和其他问题。

根据泄漏的类型,您可以使用umdh或debugdiag作为简单的工具,否则我会推荐windbg。所有这些都是免费的,并且是Windows调试工具的一部分,您可以Google以获取有关所有这些工具的教程。在windbg中自动查找泄漏的命令是!heap -l。