How do I begin debugging a python memory leak?

Discussion in 'Python' started by Matthew Wilson, Sep 17, 2009.

  1. 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?
     
    Matthew Wilson, Sep 17, 2009
    #1
    1. Advertising

  2. Matthew Wilson schrieb:
    > 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
     
    Diez B. Roggisch, Sep 17, 2009
    #2
    1. Advertising

  3. guppy-pe
    On Sep 16, 8:10 pm, Matthew Wilson <> wrote:
    > 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?
     
    Andrew Svetlov, Sep 17, 2009
    #3
  4. Matthew Wilson

    Rainer Grimm Guest

    On 17 Sep., 02:10, Matthew Wilson <> wrote:
    > 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
     
    Rainer Grimm, Sep 18, 2009
    #4
  5. Matthew Wilson

    Paul Rubin Guest

    Rainer Grimm <> writes:
    > have a look at valgrind.


    Have you actually used that on Python?
     
    Paul Rubin, Sep 18, 2009
    #5
  6. Matthew Wilson

    Rainer Grimm Guest

    On Sep 18, 5:42 pm, Paul Rubin <http://> wrote:
    > Rainer Grimm <> writes:
    > > have a look at valgrind.

    >
    > 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.
     
    Rainer Grimm, Sep 18, 2009
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Erwin Dahl
    Replies:
    2
    Views:
    425
    Michael Hudson
    Nov 5, 2003
  2. s.subbarayan

    Dynamic memory allocation and memory leak...

    s.subbarayan, Mar 18, 2005, in forum: C Programming
    Replies:
    10
    Views:
    707
    Eric Sosman
    Mar 22, 2005
  3. Richard Heathfield

    Leak or no leak ??

    Richard Heathfield, Jul 10, 2006, in forum: C Programming
    Replies:
    4
    Views:
    353
    Richard Heathfield
    Jul 10, 2006
  4. cham
    Replies:
    5
    Views:
    772
  5. Mark Probert
    Replies:
    4
    Views:
    331
    Mark Probert
    Feb 9, 2005
Loading...

Share This Page