|
|
Suppose that we have a dynamically allocated object A, which has as
member a reference to a dynamically allocated object B (allocated by A),
which has a reference to a dynamically allocated object C (allocated by B),
and so on. That is, a long chain of objects, each allocating and owning the
next one.
Now the reference to A in the actual program code dies, so A is not owned
by anything anymore. The GC engine kicks in at some point. Does it free all
those objects, or does it free A only (and when it's run again at some point
in the future, it frees B only, etc)?
I assume that it frees all the objects, not just A, but how does it do
it efficiently? (I assume this because else in a circular ownership
situation it would never free any of the objects.)
Assume that this chain of objects is very large, consisting of thousands
of objects.
--
- Warp
Post a reply to this message
|
|