[fpc-pascal] Leak narrowed down

Jonas Maebe jonas.maebe at elis.ugent.be
Wed Oct 27 18:40:46 CEST 2010


On 27 Oct 2010, at 18:18, Tobias Giesen wrote:

> I have narrowed the leak down. It's not in FPC. It's in the LCL or most
> likely in the Carbon interface. It leaks memory outside of the FPC heap.
> Probably some CFStrings or other Carbon data types.
> 
> It's caused be the following line:
> 
> Lb.Width:=Lb.Canvas.GetTextWidth(Lb.Caption);
> 
> For now I can avoid doing this. If I come up with a fix, I'll post it to
> the Lazarus list.

Before starting your program, set the following environment variable:

export MallocStackLogging=1

Then, once the program is running and has leaked memory, run

leaks nameofyourprogram

It will print all allocation sites of memory blocks that are no longer reachable. Note that it can also give false positives, but given the fact that you already identified one culprit it shouldn't be too difficult to extract the relevant ones.


Jonas


More information about the fpc-pascal mailing list