Recent

Author Topic: [SOLVED]question about heaptrc  (Read 9423 times)

thierrybo

  • Full Member
  • ***
  • Posts: 146
[SOLVED]question about heaptrc
« on: September 12, 2009, 08:29:29 pm »
I just test using heaptrc for the first time. After reading some stuff about it, I only need to check -gh option for the project. I works because I have now

Heap dump by heaptrc unit
0 memory blocks allocated : 0/0
0 memory blocks freed     : 0/0
0 unfreed memory blocks : 0
True heap size : 0
True free heap : 0

However , to test it, I just added

Code: [Select]
var
  BitmapTemp : TBitmap;
begin
  BitmapTemp := TBitmap.Create;

to create leak in an empty form with a button, that delphi memory manager detetc :

Quote
An expected memory leak has occured, the unexpected small block leak are:

53-60 bytes: TBitmap x 1
109-116 bytes: TBitmapImage x 1

Why Lazarus heaptrc still output nothing

Quote
Heap dump by heaptrc unit
0 memory blocks allocated : 0/0
0 memory blocks freed     : 0/0
0 unfreed memory blocks : 0
True heap size : 0
True free heap : 0

with just a simple example? Is there some other options to set to make it run properly?
« Last Edit: September 14, 2009, 07:52:14 pm by thierrybo »

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1946
Re: question about heaptrc
« Reply #1 on: September 12, 2009, 09:54:07 pm »
Works here doing nothing special with this code:

Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
begin
  TBitmap.create;
end;    

using Lazarus 0.9.29 r21460M FPC 2.2.4 i386-linux-gtk 2 (beta)

Code: [Select]
Heap dump by heaptrc unit

1452 memory blocks allocated : 985563/990608

1450 memory blocks freed     : 985375/990416

2 unfreed memory blocks : 188

True heap size : 229376

True free heap : 229056

Should be : 229072

Call trace for block $B7FD77C8 size 124

  $080698F2

  $081043C8  TRASTERIMAGE__CREATE,  line 274 of ./include/rasterimage.inc

etc...

thierrybo

  • Full Member
  • ***
  • Posts: 146
Re: question about heaptrc
« Reply #2 on: September 12, 2009, 11:25:57 pm »
Uhm,

FPC 2.2.2 / LAZ 0.9.26.2 release. I will test on svn version.

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: question about heaptrc
« Reply #3 on: September 13, 2009, 11:36:28 am »
Are you using another than default heap manager, e.g. cmem? Then no memory is allocated through fpc's memory manager and heaptrc doesn't detect it.

thierrybo

  • Full Member
  • ***
  • Posts: 146
Re: question about heaptrc
« Reply #4 on: September 14, 2009, 07:31:13 pm »
No,

I am not using another heap manager. But I noticed it works as expected if I include heaptrc unit manually  :

Code: [Select]
heap dump by heaptrc unit
3404 memory blocks allocated : 1156013/1167024
3402 memory blocks freed     : 1155725/1166736
2 unfreed memory blocks : 288
True heap size : 196608
True free heap : 196032
Should be : 196096
Call trace for block $00007FC413CD4950 size 184
  $000000000049858B
  ....
Call trace for block $00007FC413B23D90 size 104
  $000000000049858B
...

Theo, did you use heaptrc manually or through project option?

I also tested with lazarus-testing debian repository (Lazarus 0.9.27-0-20090831 and FPC 2.2.2-4) on a clean virtua machine, I have the same output using project option (all zeros). But including heaptrc unit with the same example, it does not detect any unfreed memory, although I get numbers...

All my tests are done with 64bits versions.

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1946
Re: question about heaptrc
« Reply #5 on: September 14, 2009, 07:42:38 pm »
Theo, did you use heaptrc manually or through project option?
Project Options.

thierrybo

  • Full Member
  • ***
  • Posts: 146
Re: question about heaptrc
« Reply #6 on: September 14, 2009, 07:51:42 pm »
Ha,  >:D

I found. The option -gv for Valgring was also checked. With both, heaptrc output 0 for all numbers.

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: [SOLVED]question about heaptrc
« Reply #7 on: September 14, 2009, 08:09:53 pm »
Ah, I add valgrind next to cmem as examples of alternative memory managers.

 

TinyPortal © 2005-2018