GC: finalization order?!

Johannes Pfau spam at example.com
Sat Feb 19 12:34:39 PST 2011


Jonathan M Davis wrote:
>IIRC, class destructors aren't supposed to reference any references or
>pointers to the heap. They're intended for cleaning up other
>resources. I don't think that there are any guarantees with regards to
>the order of the destruction of objects which are being garbage
>collected. But I don't mess with destructors much, so I'm not all that
>well versed in the details.
>
>- Jonathan M Davis

I think destructors shouldn't use references to the _garbage collected_
heap. Freeing resources which were allocated with malloc should work.
In fact freeing C memory is the only usecase for destructors I can
think of. If you rely on destructors to release file handles / gpu
textures / other limited resources you risk to run out of those.

-- 
Johannes Pfau
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20110219/72a5deb3/attachment.pgp>


More information about the Digitalmars-d-learn mailing list