编一个含有多个dll工程和一个exe工程的项目,程序退出时提示:Dumping objects ->
{119} normal block at 0x015A63A8, 80 bytes long.
 Data: <ABCDEFGHIJKLMNOP> 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 
{118} normal block at 0x015A6338, 48 bytes long.
 Data: <                > 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 
Object dump complete.     这个没有提示在哪些文件有内存泄露。该怎么解决这类内存泄露呢?

解决方案 »

  1.   

    一般都用 BoundsChecker我记得有2种情况。一种就是部长说的,直接看行号的,但是表头是.CPP文件,楼主这种是模块映射的,很难看的,我去找下网摘:找到了这种情况我采用一种“试探法”。由于内存分配的块号不是固定不变的,而是每次运行都是变化的,所以跟踪起来很麻烦。但是我发现虽然内存分配的块号是变化的,但是变化的块号却总是那几个,也就是说多运行几次,内存分配的块号很可能会重复。因此这就是“试探法”的基础。1. 先在调试状态下运行几次程序,观察内存分配的块号是哪几个值;2.选择出现次数最多的块号来设断点,在代码中设置内存分配断点:添加如下一行(对于第 1875 个内存分配):_crtBreakAlloc = 1875;或者,可以使用具有同样效果的 _CrtSetBreakAlloc 函数:_CrtSetBreakAlloc(1875); //我把这句放在了InitiaDialog里面3. 在调试状态下运行序,在断点停下时,打开“调用堆栈”窗口,找到对应的源代码处;4.退出程序,观察“输出窗口”的内存泄露报告,看实际内存分配的块号是不是和预设值相同,如果相同,就找到了;如果不同,就重复步骤3,直到相同。5. 最后就是根据具体情况,在适当的位置释放所分配的内存。
      

  2.   


        找不到支持VS 2008 的boundchecker。
      

  3.   


        我设置了_CrtSetBreakAlloc(119); ,但是还是没有中断啊!
      

  4.   


    程序退出时输出窗口就这样提示:Dumping objects ->
    {119} normal block at 0x015A63A8, 80 bytes long.
     Data: <ABCDEFGHIJKLMNOP> 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 
    {118} normal block at 0x015A6338, 48 bytes long.
     Data: < > 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 
    Object dump complete.    VS 2008有可能误报吗?
      

  5.   

    可以试试在0x015A63A8和0x015A6338处设置内存改变断点。
    Setting a Breakpoint When the Value at a Specified Memory Address Changes
    To break when the value at a specified memory address changes From the Edit menu, click Breakpoints.
    Click the Data tab of the Breakpoints dialog box.
    In the Expression text box, type the memory address for the byte. 
    For a word or doubleword memory address, enclose the address in parentheses, and precede it with a cast operator. For example, WO(21406036) for the word at memory location 21406036. Use the cast operator BY for a byte (optional), WO for a word, or DW for a doubleword. (The debugger interprets all integer constants as decimal unless they begin with zero (0) for octal or zero and x (0x) for hexadecimal.)In the Number Of Elements text box, type the number of bytes, words, or doublewords to monitor. If you used the BY operator in the Expression field, specify the number of bytes. If you used WO, specify the number of words. If you used DW, specify the number of doublewords. 
    Click OK to set the breakpoint. 
      

  6.   


        赵大侠,我照你的意思新建了一个数据断点,在运行程序时没有触发断点,关闭程序时触发了,调试结果如下图:      我也不知是哪个模块出问题,里面有一句[下面的框架可能不正确和/或缺失,没有为 boost_filesystem-vc90-mt-gd-1_42.dll 加载符号],那么是不是boost_filesystem-vc90-mt-gd-1_42.dll这个有问题呢?   
      

  7.   


        VLD是个玩具而已,小程序可以,大程序不行。