[fpc-pascal] Problem with heaptrc

Xiangrong Fang xrfang at gmail.com
Sun Nov 9 14:58:58 CET 2014


Hi All,

I use heap trace utility to see if there are memory leak in my program.
The source is here:

https://github.com/xrfang/fpcollection/blob/aefa04f0374c94298facd8d57d4a25dafe10b753/src/demos/cache/demo.lpr

My problem is, at the beginning of the main program, I have a costant
definition:

const
  ITEM_COUNT = 5000000;
If I set ITEM_COUNT to a small value, say 50 or 5000, everything is OK, no
memory leak. But with the above value, it will cause HEAPTRC to fall in an
endless loop, generating messages like:

Call trace for block $00007F41693AA680 size 40
  $000000000040071F line 29 of demo.lpr
  $0000000000400180

While line 29 is this:

27  for i := 0 to ITEM_COUNT - 1 do begin
28    for j := 0 to 4 do key[j] := $deadbeef + i + j;
29    h.Add(@key, SizeOf(PtrUInt) * 5, Pointer($deadbeef + i));
30  end;
Could anyone tell me why heaptrc will fall in an endless loop, and does my
program have memory leak?

Thanks!

Xiangrong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20141109/25b0e167/attachment.html>


More information about the fpc-pascal mailing list