C API: Testing my reference counting

"Martin v. Löwis" martin at v.loewis.de
Mon Mar 20 09:28:57 CET 2006


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).

HTH,
Martin



More information about the Python-list mailing list