If GC starts destroying some group of the objects, it could be more correct, if the calls of dtros are occured of all objects in a group before phisical memory releasing. Or GC must call dtors of the objetcts only, which noone refers to.
GC has a "barbaric" destroyng model, I think
Andrey Derzhavin via Digitalmars-d-learn Wed, 11 Feb 2015 13:35:39 -0800
If we are using a DMD realization of destroying of
objects, happens the following: at the calling the «destroy»
method the calling of dtor takes place always, and then the
object which is being destroyed is initialized by the default
state. In other words, after calling «destroy» method, there is
no way of getting an access to the members of the object that is
being destroyed (it is meant, that the members are the
references). GC works the same way.
This approach in case of manual calling of «destroy» method has
predictable and understandable consequences (there is no reasone
to use the object being destroyed). But if GC performes the
destroying of the objects, a lot of errors appear at the
accessing to the members which are references, because some of
them have already been destroyed (access to the members is
realized in dtors). Such situations can be avoided, by using
«@nogc» keyword. Howewer «@nogc» keyword doesn't protect us from
using the references in dtors: we can assign some values to the
refernces, we can have access to some members by the references
and assign them some values.That is not correct in itself.
- GC has a "barbaric" des... Andrey Derzhavin via Digitalmars-d-learn
- Re: GC has a "barbaric&... Orvid King via Digitalmars-d-learn
- Re: GC has a "barba... Jonathan M Davis via Digitalmars-d-learn
- Re: GC has a "barbaric&... ketmar via Digitalmars-d-learn
- Re: GC has a "barba... Mike Parker via Digitalmars-d-learn
- Re: GC has a "b... Kagamin via Digitalmars-d-learn
- Re: GC has a &qu... Jonathan M Davis via Digitalmars-d-learn
- Re: GC has a &qu... weaselcat via Digitalmars-d-learn
- Re: GC has ... Mike Parker via Digitalmars-d-learn
- Re: GC ... ponce via Digitalmars-d-learn
- Re:... via Digitalmars-d-learn