[Gc] Circular references
scholz at scriptolutions.com
Wed Feb 27 01:53:32 PST 2008
Wednesday, February 27, 2008, 4:40:39 PM, you wrote:
CG> Aleksey Demakov wrote:
>> There is no need to break circular references for garbage
>> collector to detect garbage.
CG> If had previously defined GC_DEBUG I would have seen the appropriate
CG> finalization warnings in the log file. However the finalizers do not
CG> run. Are they supposed to? The documentation for
CG> GC_register_finalizer() in gc.h is not quite clear to me:
CG> "Any finalizable object that is reachable from itself by following one
CG> or more pointers will not be finalized (or collected)."
CG> To my understanding that says, that doubly linked objects neither get
CG> finalized nor even collected.
Linked lists of objects that have finalizers are evil. Hans is using
this always as an example for the worst case scenario. The solution is
to move the finalization part out of the linked node list. So that the
data structure that does need finalization has a next/prev links.
I think every modern container library is using node structures
instead of intrinsic links anyway.
Lothar Scholz mailto:scholz at scriptolutions.com
More information about the Gc