CRT 调试堆函数:
#define CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>和_CrtDumpMemoryLeaks();要放在哪里的~????不太清楚,BoundsChecker的话运行的时候太慢了,我装了个,现在都不知道怎么卸载了~?

解决方案 »

  1.   

    在cpp代码前面加入:
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #endif
      

  2.   

    以下这篇文章正好回答你的问题(有图解):
    如何调试MFC中的内存泄漏 
    http://www.cnitblog.com/wangk/archive/2005/12/14/5369.aspx
      

  3.   

    F:\CodeSample\Test\TestPipe\LeakTest\MainFrm.cpp(54) : {86} normal block at 0x00422E80, 10 bytes long.
     Data: <          > 1F 1F 1F 1F 1F CD CD CD CD CD 就是这些不会出现啊`
    我的都是
    Loaded 'C:\WINDOWS\system32\MSCTF.dll', no matching symbolic information found.
    Loaded 'C:\WINDOWS\system32\version.dll', no matching symbolic information found.
    Loaded 'C:\WINDOWS\system32\MSCTFIME.IME', no matching symbolic information found.
    Loaded 'C:\WINDOWS\system32\ole32.dll', no matching symbolic information found.
    The thread 0xDA8 has exited with code 0 (0x0).
    The program 'C:\Documents and Settings\user\桌面\新\越强\Release\FlwData.exe' has exited with code 0 (0x0).
      

  4.   

    #include <windows.h>
    #include <crtdbg.h>
    void main()
    {
    char * pstr;
    pstr = new char[5];
    _CrtDumpMemoryLeaks();
    }
    自己新建的一个这样可以的~~是C++的;
    我的程序现在是MFC的,要怎么做啊~?
      

  5.   

    用软件吧,比如:BoundsChecker
      

  6.   

    不知道。 
    设置断点 debug 不知能否解决
      

  7.   

    我啊~?不知道啊~~~我也晕呢,我在自己的电脑上的时候怎么用都可以`到了客户那里的话,有的人就不行了~用着用着会出来内存不足,还会出现什么错误,软件一下子就关掉了,长时间用着的话好像也会死机的~晕啊~~~~用了BoundsChecker好像有的不是自己程序里的内存泄漏的~MFC自带的也会~~~~~真是无语了
      

  8.   

    MFC可以用DumpMemoryLeaks的方法,而且内存泄漏检查工具那么多。
      

  9.   

    MSDN: 《Detecting and Isolating Memory Leaks Using Microsoft Visual C++》
      

  10.   

    调试时没显示内存泄漏可能是你调试过程中代码没有覆盖到有内存泄漏的地方啊另外楼上推荐的MSDN文章可好好看一看
      

  11.   

    BoundsChecker是模拟你申请内存的行为,你运行时间长一点看看
      

  12.   

    http://cnboy.blogchina.com/blog/829049.html