Tracking memory leaks
nas at python.ca
Tue Nov 13 21:52:14 CET 2001
Jonathan M. Gilligan wrote:
> I have problems with an application that makes heavy use of Numeric and
> calldll. The problem is that it leaks memory like a seive (at each iteration
> of a loop in which large Numeric arrays are created and (I hope) destroyed,
> python's memory use skyrockets. I have invoked gc.set_debug and there are no
> unreachable objects, but the third-generation object store gets bigger and
> bigger each time through the loop.
Make sure there are no objects in the gc.garbage list. If there are
then you have objects with __del__ methods that are involved in a
reference cycle. If there are not, then you've most likely got a
reference counting bug somewhere.
> I am sure that the problem is with my code, not with the core of Python or
> Numpy, but I would really like to get to the bottom of this. Is there any
> good way for me to get python to dump a list of all the Python objects in
The gc module in Python 2.2 has a get_objects() method that would be
useful in debugging this problem. It returns all of the objects tracked
by the GC.
More information about the Python-list