[Gc] Circular references

Lothar Scholz scholz at scriptolutions.com
Wed Feb 27 01:50:11 PST 2008


Hello Aleksey,

Wednesday, February 27, 2008, 3:39:50 PM, you wrote:

AD> Hi Christian,

AD> On Wed, Feb 27, 2008 at 1:41 PM, Christian Gudrian
AD> <gn at fluidon.dyndns.info> wrote:
>>  I am using a doubly linked list of garbage collected objects which does
>>  not get collected properly (because of the circular references I
>>  presume).  Do I need to iterate through the list and break these
>>  circular references or is there an appropriate mechanism in the
>>  collector I am unaware of?
>>

AD> There is no need to break circular references for garbage
AD> collector to detect garbage. As long as objects are not
AD> reachable from gc roots they are subject to garbage
AD> collection.

Thats the theory. Now back to the real life. Yes you should. If it is
easy then set the pointers to NULL otherwise hope that there arent
too many false positives (arrays of real number are really dangerous).

I did some measurements and the effect of this little implementation
was huge. Hint: You might want to consider calling gc_free to
explicitly free large data structure to reduce the memory footprint.



-- 
Best regards,
 Lothar Scholz                mailto:scholz at scriptolutions.com



More information about the Gc mailing list