class destructors and sub-objects
d coder
dlang.coder at gmail.com
Thu Aug 29 06:58:11 PDT 2013
Greetings
I have a question on class destructor method. D documentation for
destructors says:
"The garbage collector is not guaranteed to run the destructor for
all unreferenced objects. Furthermore, the order in which the garbage
collector calls destructors for unreference objects is not
specified. This means that when the garbage collector calls a
destructor for an object of a class that has members that are
references to garbage collected objects, those references may no
longer be valid. This means that destructors cannot reference sub
objects."
Now I have a class A and it refers to subobject B. But B may or may not
have other objects referring to it. As a result, an object of A is GCed,
but subobject B may or may not be getting garbage collected.
In this scenario, am I allowed to make a reference to subobject B from the
destructor of A? Is there a way to find out if B is garbage collected or
not?
Regards
- Puneet
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20130829/471c8f09/attachment.html>
More information about the Digitalmars-d-learn
mailing list