[Gc] Re: GC needs to be invoked manually
martin.wartens at mymail.ch
Mon Aug 15 14:24:43 PDT 2005
> Nothing's destroyed yet because there's still a root pointer,
> someElement, on the stack at this point.
That someElement is still alive shouldn't prevent the collection of n1 and n2.
someElement is a shared "leaf" from the standpoint of the tree structure, so it
shouldnt't prevent the collection of elements that point to it. Also moving the
creation of someElement into the loop doesn't change the problem.
> Try adding an explicit call to the collector here, then move the 2 cout
> calls in testgc to after the collector call.
I did that, the result is: with the first call to GC_gcollect(), all the n2s
are collected. n1 and someElement are only collected with a second call to
More information about the Gc