在vc中加入
#define _CRTDBG_MAP_ALLOC
#include "stdlib.h"
#include <crtdbg.h>
以及在程序最后加入 _CrtSetReportMode(_CRT_ERROR,_CRTDBG_MODE_DEBUG);   _CrtDumpMemoryLeaks();
检测内存泄露,结果如下:
Detected memory leaks!
Dumping objects ->
C:\Users\chubin\Desktop\117一号车位dixiacheweiC\chewei.c(117) : {9663} normal block at 0x02C68800, 112829 bytes long.
 Data: <4AFL[b_\a^_MF&  > 34 41 46 4C 5B 62 5F 5C 61 5E 5F 4D 46 26 18 1E 
{4855} normal block at 0x017B3548, 12800 bytes long.
 Data: < E   xe@ E    e@> A1 45 B6 F3 FD 78 65 40 A2 45 B6 F3 FD 98 65 40 
{4854} normal block at 0x017B0300, 12800 bytes long.
 Data: < E   xe@ E   xe@> A1 45 B6 F3 FD 78 65 40 A1 45 B6 F3 FD 78 65 40 结果中的第一个内存泄露双击可以找到泄露地点,而下面的其他泄露则无法通过双击查看,请问如何解决这个问题以解决内存泄露?

解决方案 »

  1.   

    你看一下你工程中的一些cpp文件,是否都加:
    #ifdef _DEBUG
    #define new DEBUG_NEW
    ........
      

  2.   

    加上这个会出错.....fatal error C1070: mismatched #if/#endif pair in file这个是为什么?比较菜
      

  3.   

    再加上#endif就可以了吧?是说全加上就会能显示了吗?
      

  4.   

    加上了#ifdef _DEBUG
    #define new DEBUG_NEW
    #endif
    还是没有办法双击查找到错误.....
      

  5.   

    没有使用MFC.......是win32控制台程序,.c文件