On Saturday 19 February 2011 12:34:39 Johannes Pfau wrote: > 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.
Yes. You're right. They can reference the non-GC heap just fine. It's just that they can't reference the GC heap - probably because the destructor order is indeterminate and so that the GC doesn't have to worry about dealing with circular references between garbage collected objects. - Jonathan M Davis
