Einzelnen Beitrag anzeigen

Benutzerbild von Mavarik
Mavarik

Registriert seit: 9. Feb 2006
Ort: Stolberg (Rhld)
4.130 Beiträge
 
Delphi 10.3 Rio
 
#2

AW: MemoryLeak bei TList<IMyInterface>

  Alt 23. Feb 2015, 12:10
Ich bin noch nicht dazu gekommen, das mal in einem Testprojekt nachzubauen (kann ich erst heute Abend).
hmm mit XE7 kein Problem...

Delphi-Quellcode:
  IFoo = Interface
    ['{FD7BFFD9-1F75-4580-8C4A-375223FA0953}']
  End;

  TFoo = Class(TInterfacedObject,IFoo)
    Public
      Procedure beforeDestruction;Override;
  end;

var
  Form37: TForm37;

implementation

Uses System.Generics.Collections;

{$R *.dfm}

procedure TForm37.Button1Click(Sender: TObject);
var
  Foo : IFoo;
  List : TList<IFoo>;
begin
  Foo := TFoo.Create;
  List := TList<IFoo>.Create;
  List.add(Foo);
  List.free;
end;

{ TFoo }

procedure TFoo.beforeDestruction;
begin
  Form37.Caption := 'Free!';
  Inherited;
end;
Mavarik
  Mit Zitat antworten Zitat