C API: Testing my reference counting
neil.toronto at gmail.com
Thu Mar 23 06:02:41 CET 2006
Martin v. Löwis wrote:
> lord trousers wrote:
> > Is there a way I can get hold of these kinds of statistics for
> > debugging?
> This is best done when Python is build in debug mode.
> sys.gettotalrefcount then gives you the number of INCREF
> calls for which no DECREF has been made; you said that
> this shouldn't change.
> If it does change, sys.get_counts() will give you the
> number of objects per type.
> Furthermore, sys.getobjects() will give you a list of
> all objects allocated (excluding the result list).
Wonderful! That's just what I was looking for.
Is this kind of thing documented somewhere public? (As attributes that
only show up in the debug build, they aren't documented in the regular
library docs.) There might be more nifty goodies like this, and I'd
like to check them out.
More information about the Python-list