gc.get_referrers trouble

Jeremy Bowers jerf at jerf.org
Tue Sep 7 20:12:55 CEST 2004


On Tue, 07 Sep 2004 20:00:58 +0200, Diez B. Roggisch wrote:

> Hi,
> 
> I'm in the process of debugging a mem-leaking app. A recent thread here on
> c.l.py mentioned the use of the gc module, so I gave it a try.
> 
> However, using get_referrers() yields in literally thousands of objects for
> even the tiniest example like this:
> 
> import gc
> a = [1]
> print  gc.get_referrers(1)

For space reasons, small ints are re-used. You get thousands of referrers
to the number 1 because, well, there are!

Try this:

import gc
a = [4444444444444]
print gc.get_referrers(4444444444444)


and you'll get something much more reasonable:

[(None, 4444444444444L), [4444444444444L]]





More information about the Python-list mailing list