CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2012
    Posts
    10

    Leak: Allocation Number increasing by one when reported

    Hi guys i have a memory leak in my program which the memory allocation number is increasing by one everytime its reported. I wanted to put a break point on it but I'm wondering if that allocation number make sense. Any idea what does it mean and how to track this? Here is the actual memory leak.

    Code:
    Detected memory leaks!
    Dumping objects ->
    {1986} normal block at 0x01CD66B0, 88 bytes long.
     Data: < lE             > 8C 6C 45 10 00 00 00 00 CD CD CD CD 00 00 00 00 
    Object dump complete.
    Detected memory leaks!
    Dumping objects ->
    {1986} normal block at 0x01CD66B0, 88 bytes long.
     Data: < lE             > 8C 6C 45 10 00 00 00 00 CD CD CD CD 00 00 00 00 
    Object dump complete.
    The program '[2232] GLI_HarryTrotter_d.exe: Native' has exited with code 0 (0x0).
    that allocation number {1986} will be come {1987} next time the leak is reported.
    Last edited by himitsujanai; February 17th, 2012 at 11:26 AM.

  2. #2
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: How to clear vector of pointers inside static library

    Well, from your snippet, it does not look like memory allocation number increases. That means memory leak source is created by the same sequence (the same place in the source).
    It would be helpful to see filename and line numbers where allocation takes place.
    If you are using malloc, define following:

    Code:
    #ifndef _CRTDBG_MAP_ALLOC
    #define _CRTDBG_MAP_ALLOC
    #endif
    Place this block in your stdafx.h file before any include. You may have to also include stdlib.h and crtdbg.h after the above #define.
    If you are using C++ new to allocate heap memory define make sure the suspect cpp file contains:

    Code:
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #endif
    If not add it; new VS does not inset it automatically for added classes. Only files generated by tha ap wizard cintain this.

    If you are using VS 2008 and above you will use this since

    DEBUG_NEW is defined in afx.h. if you have any probllems use the following:

    Code:
    #ifdef _DEBUG
       #ifndef DBG_NEW
          #define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
          #define new DBG_NEW
       #endif
    #endif
    If you follow all of the above, you should see filename and the line number before memory allocation number.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured