Measure the amount of memory used?

J

Jack Bates

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?
 
J

John Gordon

In said:
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.
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top