Next: , Previous: , Up: Garbage Collection - Step by Step   [Contents][Index]

11.4.5 sweep_lcrecords_1

After nullifying the complete lcrecord statistics, we go over all lcrecords two separate times. They are all chained together in a list with a head called all_lcrecords.

The first loop calls for each object its finalizer method, but only in the case that it is not read only (C_READONLY_RECORD_HEADER_P), it is not already marked (MARKED_RECORD_HEADER_P), it is not already in a free list (list of freed objects, field free) and finally it owns a finalizer method.

The second loop actually frees the appropriate objects again by iterating through the whole list. In case an object is read only or marked, it has to persist, otherwise it is manually freed by calling xfree. During this loop, the lcrecord statistics are kept up to date by calling tick_lcrecord_stats with the right arguments,