Python Memory Manager

"Martin v. Löwis" martin at v.loewis.de
Sun Feb 17 16:44:14 EST 2008


>> Also, if it does, how does it deal with memory segmentation? This
>> question bothers me because I've been trying to implement a moving
>> garbage collector, and am not sure how to deal with updating all
>> program pointers to objects on the heap, and thought perhaps an answer
>> to this question would give me some ideas. 
> 
> As I understand it, Python primarily uses reference counting, with a
> mark and sweep scheme for cycle breaking tacked on as an afterthought.

That's not exactly true, i.e. it isn't mark-and-sweep, but some similar
scheme that allows incremental collection without write barriers. This
particular scheme heavily relies on refcounting itself (specifically,
an object is garbage in a certain generation when all references to
it come from the same generation).

As for the consequences of the scheme (i.e. no compaction), you are
right.

Regards,
Martin



More information about the Python-list mailing list