Memory leak on TFPGInterfacedObjectList
Original Reporter info from Mantis: jcmoraisjr
-
Reporter name: Joao Morais
Original Reporter info from Mantis: jcmoraisjr
- Reporter name: Joao Morais
Description:
Whenever I add interfaced objects to a TFPGInterfacedObjectList, those objects apparently add two references, while release only one when the list is cleaned or destroyed.
Steps to reproduce:
The following code shows:
==========>>>==========
$ /tmp/project1
just before vl.add(v1)..: 1
just after vl.add(v1)...: 3
after destroy the list..: 2
Heap dump by heaptrc unit
9 memory blocks allocated : 773/784
8 memory blocks freed : 757/768
1 unfreed memory blocks : 16
True heap size : 622592 (32 used in System startup)
True free heap : 622464
Should be : 622480
Call trace for block $000F31E0 size 16
$000210DF _P$PROJECT1_finalize_implicit, of /private/tmp//tmp/project1.lpr
$00021EF1 _P$PROJECT1_finalize_implicit, of /private/tmp//tmp/project1.lpr
$00020E4F _P$PROJECT1_finalize_implicit, of /private/tmp//tmp/project1.lpr
==========<<<==========
The code:
==========>>>==========
program Project1;
uses
heaptrc, fgl, sysutils;
type
i1 = interface(iinterface)
function ref: integer;
end;
tl = specialize TFPGInterfacedObjectList<i1>;
t1 = class(TInterfacedObject, i1)
public
function ref: integer;
end;
var
v1: i1;
vl: tl;
function t1.ref: integer;
begin
result := frefcount;
end;
begin
v1 := t1.create;
vl := tl.create;
try
writeln('just before vl.add(v1)..: ', v1.ref);
vl.add(v1);
writeln('just after vl.add(v1)...: ', v1.ref);
vl.Clear;
finally
freeandnil(vl);
end;
writeln('after destroy the list..: ', v1.ref);
end.
==========<<<==========
Mantis conversion info:
- Mantis ID: 25635
- OS: Mac OS X
- OS Build: 10.8
- Platform: i386
- Version: 2.6.3
- Fixed in version: 3.0.0
- Fixed in revision: 26714 (#0e68cb64)
- Target version: 3.0.0