[fpc-pascal] Usage of TInterfacedObject. Automatic release?
cesarliws at gmail.com
Sat May 26 21:05:23 CEST 2007
> 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.
- As Joao suggest, the best way is create a weak reference, where when 2
objects need to reference each other one should use Pointer to hold one
- Avoid circular reference
- Create a Finalization method that will set one of the references to "nil"
More information about the fpc-pascal