In our previous episode, Juha Manninen (gmail) said:
> I have a program that creates a TInterfacedObject and nothing else.
> 
> program project1;
> {$mode objfpc}{$H+}
> uses
>   Classes;
> var
   io: IUnknown;
> begin
>   io := TInterfacedObject.Create;
> end.


Try the above program.
       
> If I add "io.free" then there are no unfreed memory blocks.
> Now, I have understood interfaced objects are reference counted and freed 
> automatically. Is this a bug or did I understand it wrong?

Yes you understood it wrong. The interface references are reference counted,
the object references don't suddenly become ref-counted.

It is a common trap though.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to