Measure the amount of memory used?

Discussion in 'Python' started by Jack Bates, Aug 18, 2011.

  1. Jack Bates

    Jack Bates Guest

    I wrote a content filter for Postfix with Python,
    https://github.com/jablko/cookie

    It should get started once, and hopefully run for a long time - so I'm
    interested in how it uses memory:

    1) How does the amount of memory used change as it runs?

    2) How does the amount of memory used change as I continue to hack on
    it, and change the code?

    My naive thought was that I'd periodically append to a file, the virtual
    memory size from /proc/[pid]/stat and a timestamp. From this a could
    make a graph of the amount of memory used as my content filter runs, and
    I could compare two graphs to get a clue whether this amount changed as
    I continue to hack

    - but some Googling quickly revealed that measuring memory is actually
    quite complicated? Neither the virtual memory size nor the "resident set
    size" accurately measure the amount of memory used by a process

    Has anyone else measured the memory used by a Python program? How did
    you do it?
     
    Jack Bates, Aug 18, 2011
    #1
    1. Advertising

  2. Jack Bates

    John Gordon Guest

    In <> Jack Bates <> writes:

    > 1) How does the amount of memory used change as it runs?


    I've observed that the amount of memory consumed by a program will
    stay constant or increase; it never decreases.

    Or were you wanting to measure the rate of increase over time?

    > Has anyone else measured the memory used by a Python program? How did
    > you do it?


    I generally use 'top' to do this for any program.

    --
    John Gordon A is for Amy, who fell down the stairs
    B is for Basil, assaulted by bears
    -- Edward Gorey, "The Gashlycrumb Tinies"
     
    John Gordon, Aug 18, 2011
    #2
    1. Advertising

  3. Jack Bates

    MrJean1 Guest

    Take a look it this recipe (for Linux only):

    <http://code.activestate.com/recipes/286222/>

    /Jean

    On Aug 18, 8:08 am, Jack Bates <> wrote:
    > I wrote a content filter for Postfix with Python,https://github.com/jablko/cookie
    >
    > It should get started once, and hopefully run for a long time - so I'm
    > interested in how it uses memory:
    >
    >  1) How does the amount of memory used change as it runs?
    >
    >  2) How does the amount of memory used change as I continue to hack on
    > it, and change the code?
    >
    > My naive thought was that I'd periodically append to a file, the virtual
    > memory size from /proc/[pid]/stat and a timestamp. From this a could
    > make a graph of the amount of memory used as my content filter runs, and
    > I could compare two graphs to get a clue whether this amount changed as
    > I continue to hack
    >
    >  - but some Googling quickly revealed that measuring memory is actually
    > quite complicated? Neither the virtual memory size nor the "resident set
    > size" accurately measure the amount of memory used by a process
    >
    > Has anyone else measured the memory used by a Python program? How did
    > you do it?
     
    MrJean1, Aug 19, 2011
    #3
    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. Tom L

    how to measure memory consumption

    Tom L, Apr 13, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    467
    bruce barker
    Apr 14, 2004
  2. Guadala Harry

    Measure Memory Used By ASP.NET Application

    Guadala Harry, Oct 15, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    544
    Kevin Spencer
    Oct 15, 2004
  3. Replies:
    1
    Views:
    466
    Gordon Beaton
    May 10, 2006
  4. brett

    Amount of memory being used?

    brett, Feb 1, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    388
    bruce barker
    Feb 1, 2007
  5. Nospam
    Replies:
    3
    Views:
    111
    Jens Thoms Toerring
    Aug 14, 2007
Loading...

Share This Page