[fpc-pascal] Delegate Interface class does not seem to be referenced counted

Marcos Douglas md at delfire.net
Wed Aug 10 15:41:23 CEST 2016

On Wed, Aug 10, 2016 at 10:04 AM, Tony Whyman
<tony.whyman at mccallumwhyman.com> wrote:
> ...
> Destroying FMyInterface in the destructor does not make a difference -
> mainly because the TMyClass destructor is not being called anyway.

It should be called, but is not. Strange.
I tried to change the code to not using Application, DoRun, etc but
the result is same.

On Wed, Aug 10, 2016 at 10:14 AM, Tony Whyman
<tony.whyman at mccallumwhyman.com> wrote:> the output is:
> ...
> Creating TDelegateClass
> Creating TMyClass
> Creating TDelegateClass
> Destroying TDelegateClass
> so it is actually worse with both interfaces left dangling
> You get the same result with:
>    TMyClass = class(TInterfacedObject, IMyInterface)
>    private
>      FMyInterface: IMyInterface; // class type
>      property MyInterface: IMyInterface
>        read FMyInterface implements IMyInterface;
>    public
>      constructor Create(obj: IMyInterface); << The change
>      destructor Destroy; override;
>    end;

Yeah, I saw the same.
I think this is a bug. I not for FPC 3.0. I'm using FPC 2.6.

If no more answers, you should report this in Bugtrack.

I use Interfaces a lot, but not the 'implements' feature.

Best regards,
Marcos Douglas

More information about the fpc-pascal mailing list