Tracking down a memory leak

Bruce Dawson comments at cygnus-software.com
Sat Jan 19 23:48:13 EST 2002


Kip Macy wrote:

> I have a long running python program that typically uses 6-7MB. It can
> happily run for days without any problems, but periodically it will balloon
> and use up all available memory and swap. I'm aware that the presence of
> circular reference can defeat garbage collection.

My understanding is that garbage collection in Python was introduced solely
to deal with circular references. In other words, the presence of circular
references is the only reason for garbage collection.

You could try explicitly invoking the garbage collector. If your problem is
circular references that should free them.

Make sure you are running a version of Python that has garbage collection.
All versions of Python have reference counting and free objects when the
reference count hits zero, but garbage collection is much newer.

> Are there any recommended
> utilities or methods for determining what data structures are using up all
> available memory?
>
> Thanks.
>
>                 -Kip




More information about the Python-list mailing list