Memory leak with interfaces
Original Reporter info from Mantis: inoussa @inoussa12
-
Reporter name: Inoussa OUEDRAOGO
Original Reporter info from Mantis: inoussa @inoussa12
- Reporter name: Inoussa OUEDRAOGO
Description:
The attached progam demonstrates a interface memory leak which is not present in 2.0.2.
The problem is also present in the 2.1.1
It seems that it occured when a interface is passed as procedure parameter like this :
proc1(TTest.Create() as ITest);
Additional information:
1- When the program is compiled with 2.0.2, the results are :
[listing 2.0.2]
Creating >>> 544436
called in test
Creating >>> 544468
called in proc1
Destroying >>> 544468
Destroying >>> 544436
Remaining instances ... 0
[/listing 2.0.2]
1- When the program is compiled with 2.0.2, the results are :
[listing 2.0.2]
Creating >>> 544436
called in test
Creating >>> 544468
called in proc1
Destroying >>> 544468
Destroying >>> 544436
Remaining instances ... 0
[/listing 2.0.2]
2- When the program is compiled with 2.0.4.rc3, the results are :
[listing 2.0.4.rc3]
Creating >>> 675784
called in test
Creating >>> 676072
called in proc1
Destroying >>> 676072
Remaining instances ... 1
[/listing 2.0.4.rc3]
and the "HeapTrc" unit output are
[HeapTrc]
E:\Inoussa\Sources\lazarus\tests\interfaces\test_intf.exe
Heap dump by heaptrc unit
53 memory blocks allocated : 987/1192
52 memory blocks freed : 971/1176
1 unfreed memory blocks : 16
True heap size : 196608 (208 used in System startup)
True free heap : 196304
Should be : 196328
Call trace for block $000A4FC8 size 16
$00402608 TOBJECT__NEWINSTANCE, line 177 of
C:/lazarus/source/fpcbuild/2.0.4-rc3/fpcsrc/rtl/inc/objpas.inc
$00401B3E TINTERFACEDOBJECT__NEWINSTANCE, line 705 of
C:/lazarus/source/fpcbuild/2.0.4-rc3/fpcsrc/rtl/inc/objpas.inc
$004010CA TTEST__CREATE, line 33 of test_intf.pas
$004012C0 TEST, line 53 of test_intf.pas
$0040133F main, line 58 of test_intf.pas
$004013EE EXE_ENTRY, line 420 of system.pp
[/HeapTrc]
Mantis conversion info:
- Mantis ID: 7281
- Fixed in version: 2.2.0
- Fixed in revision: 4998 (#dde9ad47)
- Monitored by: » luizamerico (Luiz Americo)