Search code examples
delphifastmm

FastMM suddenly reports memory leaks in Graphics32


I have an empty project (it contains just a form). If I add this line to the project 'USES GR32_Image;' and run the application, FastMM shows leak in the program. FastMM is set to full debug. There is NO code in my program - except what Delphi IDE generates and except the 'uses gr32' line.

The report makes no sense. Here is the full log: http://pastebin.com/Yhev3rJ2
And here is the source code: http://pastebin.com/VjRrRiS8

I have used the Graphics32 unit before and I never had problems. Why I have this leak and why FastMM cannot generate a proper report?


Solution

  • Compile your app with full debug info, then in the linker options, make sure your debug info is in the .EXE and/or .MAP file.

    Then run FastMM with FullDebugMode, and copy/paste the resulting .TXT file in your question.

    See also this post for more tips.

    Edit:

    A good first step is to do something like this on your .TXT file:

    find "The allocation number is" < fastmmlog.txt | sort /R
    

    That gives you the first allocation number, in your case 281.

    From that, you search in the .TXT for the allocation number:

    --------------------------------2011/1/7 23:31:03--------------------------------
    A memory block has been leaked. The size is: 20
    
    This block was allocated by thread 0x1540, and the stack trace (return addresses) at the time was:
    402D80 [System][System][@GetMem]
    40388F [System][System][TObject.NewInstance]
    403C12 [System][System][@ClassCreate]
    4038C4 [System][System][TObject.Create]
    403C12 [System][System][@ClassCreate]
    403C6A [System][System][@AfterConstruction]
    457922 [GR32_Bindings][GR32_Bindings][NewRegistry]
    45807E [GR32_LowLevel][GR32_LowLevel][RegisterBindings]
    458152 [GR32_LowLevel][GR32_LowLevel][GR32_LowLevel]
    404373 [System][System][InitUnits]
    4043DB [System][System][@StartExe]
    
    The block is currently used for an object of class: TList
    
    The allocation number is: 281
    

    Here you can see, that the NewRegistry is involved in your leak.
    From there, you can start debugging to find out why it leaks.

    --jeroen