普通检测看看有无泄漏:
另见,vld检测,直接安装,包含一个头文件即可,更简单:
https://vld.codeplex.com/documentation
在代码中简单两处:
(1)添加头文件与宏定义
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
(2)添加系统函数调用
_CrtDumpMemoryLeaks();
更牛逼的是可以打印出泄漏的位置:
代码中添加头文件和宏定义:
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#ifdef _DEBUG
#define new new( _CLIENT_BLOCK, __FILE__, __LINE__)
#endif