How do I begin debugging a python memory leak?

M

Matthew Wilson

I have a web app based on TurboGears 1.0. In the last few days, as
traffic and usage has picked up, I noticed that the app went from using
4% of my total memory all the way up to 50%.

I suspect I'm loading data from the database and somehow preventing
garbage collection.

Are there any tools that might help me out with this?
 
D

Diez B. Roggisch

Matthew said:
I have a web app based on TurboGears 1.0. In the last few days, as
traffic and usage has picked up, I noticed that the app went from using
4% of my total memory all the way up to 50%.

I suspect I'm loading data from the database and somehow preventing
garbage collection.

Are there any tools that might help me out with this?

Maybe this one:

http://packages.python.org/Pympler/

Haven't used it myself so far though. I also have good experiences with
using the module gc & calculating histograms of instance-counts.

Diez
 
R

Rainer Grimm

I have a web app based on TurboGears 1.0.  In the last few days, as
traffic and usage has picked up, I noticed that the app went from using
4% of my total memory all the way up to 50%.

I suspect I'm loading data from the database and somehow preventing
garbage collection.

Are there any tools that might help me out with this?

If have one of the following plattforms
X86/Linux, AMD64/Linux, PPC32/Linux, PPC64/Linux and X86/Darwin (Mac
OS X),
have a look at valgrind.
http://valgrind.org/
I used of often for searching the memory leaks in c++. It's a great
tool to analyse your memory behaviour.

Greetings
 
R

Rainer Grimm

Have you actually used that on Python?
Not with python as far I can remember. But often with C++ executables,
as i mentioned it.
I you look at
http://valgrind.org/info/
there stands:
Valgrind has been used on programs written partly or entirely in C, C+
+, Java, Perl, Python, assembly code, Fortran, Ada, and many others.

It exists also a extension for python
http://blogs.gnome.org/jamesh/2008/03/24/python-valgrind/ , to get rid
of the false positiv errors.
So it should be worth a try.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

memory leak? 0
Python Memory Leak using SWIG 1
memory leak 26
Memory "leak"? 4
Possible memory leak? 29
Memory Leak Madness 18
Java script memory leak 2
IE6 memory leak - very fiddly 20

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top