Python Memory Manager
greg
greg at cosc.canterbury.ac.nz
Mon Feb 18 02:19:48 EST 2008
Christian Heimes wrote:
> In release builds PyObject_HEAD only contains the ref count and a link
> to the object type. In Py_DEBUG builds it also contains a double linked
> list of all allocated objects to debug reference counting bugs.
There's also a doubly-linked list used by the cycle detector,
but it doesn't hold all objects, only those that need to
participate in cyclic GC. Objects such as numbers and strings,
which don't contain references to other objects, don't need
to be on this list, since they can never be part of a cycle.
Some other immutable types such as tuples also don't need to
be on it, even though they contain references, because it's
impossible to create a cycle consisting entirely of such
objects. There has to be at least one mutable object in the
cycle, and the GC will be able to find the cycle via that
object.
--
Greg
More information about the Python-list
mailing list