On 2017-09-06 09:19, Graeme Geldenhuys wrote:
For example:


****** Compiled with FPC 3.0.2 or FPC 3.0.4 - no line info


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 ]==============================


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to