How to check what is holding reference to object

Almar Klein almar.klein at gmail.com
Wed Apr 28 14:23:54 CEST 2010


On 27 April 2010 23:08, Chris Rebert <clp2 at rebertia.com> wrote:

> On Tue, Apr 27, 2010 at 1:45 PM, Michal M <mich.mierzwa at googlemail.com>
> wrote:
> > I've just found out that one of objects is not destroyed when it
> > should be. This means that something was holding reference to this
> > object or part of it (i.e. method). Is there any way to check what
> > holds that reference? I am unable to do that just looking to the code
> > or debugging it because it is pretty complicated, but I am able to
> > invoke this situation again.
>
> gc.get_referrers(your_object) ?
>
> Docs: http://docs.python.org/library/gc.html#gc.get_referrers
>
> Cheers,
> Chris
>

Ah, it does exist! I wish I knew that two months ago, it would've saved me
some precious time ;)

Almar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100428/aabc6b38/attachment.html>


More information about the Python-list mailing list