[Python-Dev] Re: [Python-checkins] python/dist/src/Objects typeobject.c, 2.242, 2.243

Neil Schemenauer nas-python at python.ca
Fri Aug 8 12:44:22 EDT 2003

Michael Hudson wrote:
> [66427 refs] ----------------------------------.
> >>> test_descr.test_main(); gc.collect()       | leaks 46 refs
> 297                                            |
> [66473 refs] <---------------------------------:

I can't reproduce this.  It always leaks 3 references for me.  BTW, it's
probably best to disable automatic GC with gc.disable() when doing this
kind of debugging.

I vaguely recall running into a similar bug before.  I think the problem
in that case was that some tp_clear methods were not dropping all their
references and so it took more than one GC run to completely destroy the
cyclic structure.

It's also possible that this behavior is caused by reference leaks.
E.g. a reference count is too high and it takes more than one tp_clear
to get it to zero.  That shouldn't happen though since tp_clear methods
set points to NULL and use Py_XDECREF.


More information about the Python-Dev mailing list