[fpc-pascal] memory leak detection using FPC

Vincent Snijders vsnijders at quicknet.nl
Tue Sep 19 11:25:55 CEST 2006


Jonas Maebe schreef:
> 
> On 19 sep 2006, at 09:33, Graeme Geldenhuys wrote:
> 
>> So what is wrong with this code then...  When I quit the app, it says
>> I have one memory leak. What am I not freeing?
> 
> If you compile the rtl with line info, you'll see the non-freed object 
> is in the RTL:
> 
> Call trace for block $00187260 size 60
>   $0000E284 line 180 of /Users/jonas/fpc/rtl/inc/objpas.inc
>   $0000F070 line 724 of /Users/jonas/fpc/rtl/inc/objpas.inc
>   $00052158 line 16 of /Users/jonas/fpc/rtl/objpas/sysutils/sysuthrd.inc
>   $00039F0C line 1658 of /Users/jonas/fpc/rtl/objpas/classes/classes.inc
> 
> Line 1658 of classes.inc is
> 
>   GlobalNameSpace := TMultiReadExclusiveWriteSynchronizer.Create;
> 
> in the procedure CommonInit. In CommonCleanup it does:
> 
>   { GlobalNameSpace is an interface so this is enough }
>   GlobalNameSpace:=nil;
> 
> but apparently this is either not enough, or there is a bug with 
> interface reference counting (the latter is possible, since I've read 
> more things about that lately).

See also http://www.freepascal.org/mantis/view.php?id=7357.

Graeme, if you use fpc 2.1.1, then memleak of 40 bytes is not your fault.

Vincent



More information about the fpc-pascal mailing list