No line info in the memory leak output
Original Reporter info from Mantis: ggeldenhuys
-
Reporter name: Graeme Geldenhuys
Original Reporter info from Mantis: ggeldenhuys
- Reporter name: Graeme Geldenhuys
Description:
I've been using FPC 3.0.4-rc1 (as announced by Marco van de Voort) for a while now, using 64-bit FreeBSD. I've noticed that a memory leak tracelog with line info generated by the applications are not working as they did in FPC 2.6.4. I then tested with FPC 3.0.2, and it seems broken there too (I've never really used FPC 3.0.x for production code, so never noticed this sooner). The problem - there is no line information when using 3.0.2 or 3.0.4.
I compiled the program with both the -gl and -gh compiler parameters.
For example:
****** Compiled with FPC 3.0.2 or FPC 3.0.4 - no line info
[t1]$ ./project1
THook did it
Heap dump by heaptrc unit
4 memory blocks allocated : 115/120
2 memory blocks freed : 67/72
2 unfreed memory blocks : 48
True heap size : 1146880 (32 used in System startup)
True free heap : 1146496
Should be : 1146544
Call trace for block $00000008007390C0 size 32
Call trace for block $00000008007310C0 size 16
****** Compiled with FPC 2.6.4 - note the line info pointing to
****** the originating point of a memory leak
[t1]$ ./project1
THook did it
Heap dump by heaptrc unit
4 memory blocks allocated : 99/104
2 memory blocks freed : 51/56
2 unfreed memory blocks : 48
True heap size : 1146880 (32 used in System startup)
True free heap : 1146496
Should be : 1146544
Call trace for block $00000008007370C0 size 32
$0000000000400379 line 35 of project1.lpr
Call trace for block $000000080072F0C0 size 16
A complete example program to test with is added in the "Additional Information" section of this bug report.
Additional information:
The complete sample application is here:
=======================[ project1.pas ]============================
program project1;
{$mode objfpc}{$H+}
{$interfaces COM}
type
IHook = interface
['{4BCAEDD8-92D8-11E7-88D3-C86000E37EB0}']
procedure DoIt;
end;
type
THook = class(TInterfacedObject, IHook)
private
procedure DoIt;
end;
procedure THook.DoIt;
begin
writeln(ClassName + ' did it');
end;
type
TBaseClass = class(TInterfacedObject, IHook)
private
FHook: IHook;
property Hook: IHook read FHook implements IHook;
public
constructor Create;
destructor Destroy; override;
end;
constructor TBaseClass.Create;
begin
FHook := THook.Create; // FPC 2.6.4 reports a memory leak here
end;
destructor TBaseClass.Destroy;
begin
// nothing to do here
end;
var
base: IHook;
begin
base := TBaseClass.Create;
base.DoIt;
base := nil; // just to see if it helped with the memory leak - it
doesn't
end.
==============================[ end ]==============================
Mantis conversion info:
- Mantis ID: 32381
- OS: FreeBSD
- OS Build: 10.3
- Build: 3.0.4-rc1
- Platform: x86_64
- Version: 3.0.4
- Target version: 3.0.4