Recent

Author Topic: [SOLVED]Heaptrc output and meaning  (Read 6078 times)

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
[SOLVED]Heaptrc output and meaning
« on: October 24, 2011, 09:06:48 pm »
Hi all,
How can I interpret unfreed memory blocks?
Thanks.
« Last Edit: October 26, 2011, 10:46:02 am by IndianaJones »

ik

  • Jr. Member
  • **
  • Posts: 88
  • ik
    • LINESIP
Re: Heaptrc output and meaning
« Reply #1 on: October 24, 2011, 10:44:53 pm »
If I understand you correctly, it show you the last known place you did something with memory (using getmem/new or other commands like that), so you can  try and track it and understand why it is not freed and fix it.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12181
  • Debugger - SynEdit - and more
    • wiki
Re: Heaptrc output and meaning
« Reply #2 on: October 24, 2011, 11:46:21 pm »
First of all forget about the line that says "true free heap": It is build on some internals, and you will not need it.

You should look at "xxx unfreed blocks" or similar.

If it is zero, then you are good. Otherwise it tells you how much memory you lost in how many blocks of allocation. E.g if you created an object, but never destroyed it.

For each of them you get a location where the memory was allocated.

There is a package "LeakView" which you can install. It takes the output and helps you browse the files in the IDE.

It is still tricky to find what is going on.

If you leaked a TStringList, that did hold 10 strings, then you did also leak those 10 strings.
Yet looking at the code that assigns the string, does not help you closing the leak. In cases like this, you have to find out about the encapsulating object (The stringlist). But that may again have been hold by another object, that did never get destroyed (but would on destruction have released the list...)... And so on.

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
Re: Heaptrc output and meaning
« Reply #3 on: October 25, 2011, 10:34:01 am »

Thanks for the information, but how can I use the "LeakView", what is the procedure?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12181
  • Debugger - SynEdit - and more
    • wiki
Re: Heaptrc output and meaning
« Reply #4 on: October 25, 2011, 11:00:59 am »
LeakView is a package. It is in the directory components/leakview

Either open the package, and install it from the package window.
Or open the "Install/Uninstall packages" and select it there and install.

Once installed, there is a menu entry in the "Tools" menu.

Then copy the stacktrace
Code: [Select]
Call trace for block $B1E75B70 size 36
$0833C15C TFINDDECLARATIONTOOL__CHECKSRCIDENTIFIER, line 8332 of finddeclarationtool.pas
$0833C55B TFINDDECLARATIONTOOL__DOONIDENTIFIERFOUND, line 8512 of finddeclarationtool.pas
$08330835 CHECKRESULT, line 2681 of finddeclarationtool.pas

and paste it. Or if it is in a logfile, open the file.

It will display all the lines, and you can double click them

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
Re: Heaptrc output and meaning
« Reply #5 on: October 25, 2011, 11:19:58 am »

Thanks Martin,
But There is a problem with Windows7, when adding the "LeakView" package, it doesnt appear under the Tools menu.
It works for GTK2 and Mac Snow Leopard.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12181
  • Debugger - SynEdit - and more
    • wiki
Re: Heaptrc output and meaning
« Reply #6 on: October 25, 2011, 11:40:30 am »
If that is the case, then please bug report it.
It works on Win Vista, but I haven't got W7

 

TinyPortal © 2005-2018