Use __del__ methods to improve gc?

Alex Martelli aleax at aleax.it
Sun Jun 15 04:48:41 EDT 2003


Edward K. Ream wrote:

>> I suspect the paragraph you mean might be...: [snip]
> 
> That's the one.  Thanks Alex.  It is now up on my wall :-)

You're welcome!


> BTW, I'm chuckling a little less now.  Executing:
> 
> print len(gc.garbage), len(gc.get_objects())
> 
> periodically shows that my app is steadily eating memory.  len(gc.garbage)
> remains zero while len(gc.get_objects()) steadily increases.  And I
> thought I was recycling all bindings :-(
> 
> You wouldn't know of something similar to timeit for storage allocation,
> would you?

No, and I _do_ think it's a very serious issue.  You can build Python
with various switches to get more information on memory behavior, but
I've never found that to be a really satisfactory alternative.  A
"footprint profiler" that is able to trace where and roughly how much
memory is being spent/tied up would be a real boon.  The functions
get_referrers and get_referents of module gc do help, to some degree,
but it still seems to me that we're way behind in this task.


Alex





More information about the Python-list mailing list