Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Measure the amount of memory used?

Reply
Thread Tools

Measure the amount of memory used?

 
 
Jack Bates
Guest
Posts: n/a
 
      08-18-2011
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?
 
Reply With Quote
 
 
 
 
John Gordon
Guest
Posts: n/a
 
      08-18-2011
In <(E-Mail Removed)> Jack Bates <(E-Mail Removed)> 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
http://www.velocityreviews.com/forums/(E-Mail Removed) B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

 
Reply With Quote
 
 
 
 
MrJean1
Guest
Posts: n/a
 
      08-19-2011
Take a look it this recipe (for Linux only):

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

/Jean

On Aug 18, 8:08*am, Jack Bates <(E-Mail Removed)> 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?


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Measure amount of network usage hhs Cisco 13 05-28-2008 06:10 PM
Measure memory usage in Python Rune Strand Python 3 05-01-2006 02:08 PM
Measure Memory Used By ASP.NET Application Guadala Harry ASP .Net 2 10-15-2004 01:37 PM
how to measure memory consumption Tom L ASP .Net 2 04-13-2004 11:48 PM
Re: How to measure memory consumption. Sam Holden C++ 0 08-22-2003 02:01 AM



Advertisments