Looping-related Memory Leak

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Mon Jun 30 15:12:09 EDT 2008


On Mon, 30 Jun 2008 10:55:00 -0700, Tom Davis wrote:

> To me, this seems illogical.  I can understand that the GC is
> reluctant to reclaim objects that have many connections to other
> objects and so forth, but once those objects' scopes are gone, why
> doesn't it force a reclaim?  For instance, I can use timeit to create
> an object instance, run a method of it, then `del` the variable used
> to store the instance, but each loop thereafter continues to require
> more memory and take more time. 1000 runs may take .27 usec/pass
> whereas 100000 takes 2 usec/pass (Average).

`del` just removes the name and one reference to that object.  Objects are
only deleted when there's no reference to them anymore.  Your example
sounds like you keep references to objects somehow that are accumulating. 
Maybe by accident.  Any class level bound mutables or mutable default
values in functions in that source code?  Would be my first guess.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list