[Lazarus] IUnknown and reference counting

Hans-Peter Diettrich DrDiettrich1 at aol.com
Wed Mar 20 15:28:41 CET 2013


Xiangrong Fang schrieb:
> Hi,
> 
> I am reading this:
> 
> http://wiki.freepascal.org/How_To_Use_Interfaces
> 
> And wondering what's the *purpose* of "reference counting"?

Delphi (and FPC) implements garbage collection by reference counting. 
It's used in all dynamic (managed) datatypes, like arrays, interfaces, 
AnsiStrings...

> While I use 
> interface before in delphi and java, I didn't notice that I need a UUID 
> for interface. I had an impression that it has something to do with COM?

Right, an UUID/GUID for interfaces is Windows COM specific.

> So, what is the purpose of this UUID and the method provided by 
> TInterfacedObject?

The GUID allows to look up the interface definition when a type library 
(*.TLB) exists (on a Windows platform).

DoDi





More information about the Lazarus mailing list