INCREF DECREF manually
Antoine Pitrou
solipsis at pitrou.net
Mon May 10 11:17:07 EDT 2010
On Mon, 10 May 2010 07:26:42 -0700 (PDT)
moerchendiser2k3 <googler.1.webmaster at spamgourmet.com> wrote:
>
> Do to some debugging if a version contains a bug and needs to be fixed
> there manually.
This is certainly the wrong approach.
To know if your Python code is leaking references, use either
sys.getrefcount(), or (better) a weakref -- and don't forget to
call gc.collect().
To know if some C extension is buggy, use your C debugger (or your
favourite alternative debugging method, such as printf()).
Changing reference counts from Python will lead to two possible
consequences:
- if you increment a reference count, you will have a permanent memory
leak
- if you decrement a reference count, you will eventually crash the
interpreter
More information about the Python-list
mailing list