This Delphi code will show a memory leak for an instance of TMyImplementation:
program LeakTest;
uses
Classes;
type
MyInterface = interface
end;
TMyIm
TComponent._Release
does not free your instance. TInterfacedObject._Release
does free your instance.Perhaps someone can chime in but my take on this is that TComponent
is not meant to be used as a reference counted object the way we normally use interfaces.
function TComponent._Release: Integer;
begin
if FVCLComObject = nil then
Result := -1 // -1 indicates no reference counting is taking place
else
Result := IVCLComObject(FVCLComObject)._Release;
end;