hi I reported a bug for interface reference counting at http://www.freepascal.org/mantis/view.php?id=7281
Bellow is the test program. Regards, Inoussa. ==================== program test_intf; {$mode objfpc}{$H+} uses SysUtils; type ITest = interface procedure DoIt(AMsg : string); end; TTest = class(TInterfacedObject,ITest) protected procedure DoIt(AMsg : string); public constructor Create(); destructor Destroy();override; end; var InstancesCount : Integer = 0; procedure TTest.DoIt(AMsg: string); begin WriteLn(AMsg); end; constructor TTest.Create(); begin Inherited; Inc(InstancesCount); WriteLn('Creating >>> ',Integer(self)); end; destructor TTest.Destroy(); begin Dec(InstancesCount); WriteLn('Destroying >>> ',Integer(self)); inherited Destroy(); end; procedure proc1(ATest : ITest); begin ATest.DoIt(' called in proc1'); end; procedure test(); begin (TTest.Create() as ITest).DoIt(' called in test'); proc1(TTest.Create() as ITest); end; begin test(); WriteLn('Remaining instances ... ',InstancesCount); end. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal