[fpc-pascal] Where and Why is there a memory leak?

Sven Barth pascaldragon at googlemail.com
Thu Sep 7 08:02:34 CEST 2017


Am 07.09.2017 03:48 schrieb "Ryan Joseph" <ryan at thealchemistguild.com>:
>
>
> > On Sep 6, 2017, at 10:20 PM, Sven Barth via fpc-pascal <
fpc-pascal at lists.freepascal.org> wrote:
> >
> > You're missing that FHook was declared as IHook, not THook.
> >
>
> In terms of memory why does it matter how it was declared? The memory was
allocated in Create() so the declaration is just relevant for the
assignment of the new memory. Is FPC doing something magic behind the
scenes?

a) since it's an interface it doesn't *have* a Free method
b) COM interfaces are reference counted and the compiler (both Delphi and
FPC) does automatic reference counting with them (that's the purpose of
TInterfacedObject, it calls Free on itself once the reference count reaches
0)

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170907/6fee85f9/attachment.html>


More information about the fpc-pascal mailing list