Understanding the GC
Jeremy DeHaan
dehaan.jeremiah at gmail.com
Tue Jan 29 22:00:42 PST 2013
I've been reading TDPL book and was also reading some posts on
these forums about the GC, but I wanted to clarify a few things
to make sure I am understanding correctly.
From what I understand, when an object is recovered by the GC,
the destructor may or may not be called. Why is that? Is it for
performace reasons? What about the destructors of objects that
the original object contained? Are they called when the item
finally get's taken care of by the GC, or when the object is
originally recovered by the GC?
My other question is, at the end of the program will GC go
through every object it knows still holds memory and call their
destructors? My guess is that it does so that the GC ensures all
memory is successfully released before the program ends. I just
want to make sure since in http://dlang.org/class.html, it says,
"The garbage collector is not guaranteed to run the destructor
for all unreferenced objects." What exactly is an unreferenced
object?
Some other questions:
At what point is the GC called to do it's thing while the program
is running? Is it at certain intervals or is it when the
program's memory reaches a certain point?
Thanks very much for all the help!
More information about the Digitalmars-d-learn
mailing list