[Lazarus] IUnknown and reference counting

Xiangrong Fang xrfang at gmail.com
Wed Mar 20 15:35:31 CET 2013


OK, What confused me is the description found in FPC manual saying:

TInterfacedObject is a descendent of
TObject<http://www.freepascal.org/docs-html/rtl/system/tobject.html>which
implements the
IUnknown <http://www.freepascal.org/docs-html/rtl/system/iunknown.html>interface.
It can be used as a base class for all classes which need
reference counting.
in another word, reference counting is a feature of TInterfacedObject, or
the AfterConstruction/BeforeDestruction methods??  it sounds like
non-descedants of TInterfacedObject are not reference counted??

2013/3/20 Hans-Peter Diettrich <DrDiettrich1 at aol.com>

> Xiangrong Fang schrieb:
>
>  Hi,
>>
>> I am reading this:
>>
>> http://wiki.freepascal.org/**How_To_Use_Interfaces<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
>
>
> --
> ______________________________**_________________
> Lazarus mailing list
> Lazarus at lists.lazarus.**freepascal.org<Lazarus at lists.lazarus.freepascal.org>
> http://lists.lazarus.**freepascal.org/mailman/**listinfo/lazarus<http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20130320/e6939aaa/attachment-0003.html>


More information about the Lazarus mailing list