Skip to content

The pdr debugger leak memory in the target app #13

@User4martin

Description

@User4martin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions