[fpc-pascal] Usage of TInterfacedObject. Automatic release?

Luiz Americo Pereira Camara pascalive at bol.com.br
Sat May 26 22:34:18 CEST 2007

Cesar Romero wrote:
> Luiz Americo,
>> Anyway, calling manually _Release avoid the leak and i will stay with 
>> it for now (I hope did not break anything).
> It can work for that case, but I think that is not a good ideia.
> If you are using a TInterfacedObject descendant, it will call the 
> _Release when out of context, so in that especific case seems to never 
> go out of context, and then you _realease call works, but in other 
> place it can go out of context before, and the you will have others AV.

I just  realized that the current design is relatively  safe. If the 
interface goes out of context before the call to _Release, the 
referenced object will be set to nil. This will prevent a second call to 
_Release. Is not the ideal but i'll stay with it for now.

Thanks for Cesar and Joao for all that info.


More information about the fpc-pascal mailing list