这个挺有用的。记录一下.只适用于windows环境。

首先在代码头中加入:

 

//if using the check of leak memory
#define USING_LEAK_CHECK	1
#ifndef _crtdbg_map_alloc
#define _crtdbg_map_alloc
#endif

#include <stdlib.h>

#if USING_LEAK_CHECK
#include <crtdbg.h>
#endif

#include <stdio.h>

 

 

然后在程序最后加上:

 

#if USING_LEAK_CHECK
printf("check memory leak ...\n");
_CrtDumpMemoryLeaks();
printf("check over.\n");
#endif

 

 

在debug模式下进行调试,可以检测到常规的内存泄漏问题。

测试了一下,效果不错:

vs环境下的内存泄露检测工具

相关文章:

  • 2021-07-05
  • 2021-12-03
  • 2022-01-17
  • 2021-11-18
  • 2022-01-02
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
猜你喜欢
  • 2021-12-19
  • 2021-12-19
  • 2021-10-10
  • 2021-12-19
  • 2021-12-05
相关资源
相似解决方案