fqy131314

内存泄漏监测工具

Visual C++ debugger和CRT库

第一步:包含以下头文件

#define _CRTDBG _MAP _ALLOC

#include <stdlib.h>

#include <crtdbg.h>

第二步:接管new操作符

#ifdef _DEBUG

#ifndef DBG_NEW

#define DBG_NEW new(_NORMAL_BLOCK,_FILE_,_LINE_)

#define new DBG_NEW

#endif

#endif

第三步:在代码结束处输出内存泄漏信息

CrtDumpMemoryLeaks();

内存泄漏工具:

Windows:PurifyBoundsChecker、Deleaker、VisualLeakDetector(VLD)

Linux平台:Valgrind memcheck

posted on 2022-07-25 15:32  会飞的鱼-blog  阅读(16)  评论(0)    收藏  举报  来源

导航