Compiled with -gh the below does not leak memory
- Run in PDR
- pause on "writeln"
p x.Bar
c to let the app finish
Heap dump by heaptrc unit of "project1"
3 memory blocks allocated : 56
2 memory blocks freed : 36
1 unfreed memory blocks : 20
I guess, the returned string is not freed?
program project1;
{$Mode objfpc}
type
TFoo = class
private
function GetBar: AnsiString;
public
property Bar: AnsiString read GetBar;
end;
function TFoo.GetBar: AnsiString;
begin
Result := copy('abcd',1,3);
end;
var x: TFoo;
begin
x := TFoo.Create;
writeln(x.Bar);
writeln(x.Bar);
writeln(x.Bar);
x.Destroy;
end.
Compiled with -gh the below does not leak memory
p x.Barcto let the app finishI guess, the returned string is not freed?