Lawrence D'Oliveiro <l...@geek-central.gen.new_zealand> writes: > Whereas garbage collection will happen at some indeterminate time long after > the last access to the object, when it very likely will no longer be in the > cache, and have to be brought back in just to be freed,
GC's for large systems generally don't free (or even examine) individual garbage objects. They copy the live objects to a new contiguous heap without ever touching the garbage, and then they release the old heap. That has the effect of improving locality, since the new heap is compacted and has no dead objects. The algorithms are generational (they do frequent gc's on recently-created objects and less frequent ones on older objects), so "minor" gc operations are on regions that fit in cache, while "major" ones might have cache misses but are infrequent. Non-compacting reference counting (or simple mark/sweep gc) has much worse fragmentation and consequently worse cache locality than copying-style gc. -- http://mail.python.org/mailman/listinfo/python-list