views:

649

answers:

3

Is there a way we can record memory footprint? In a way that after the process has finish we still can have access to it.

The typical way I check memory footprint is this:

$ cat /proc/PID/status

But in no way it exist after the process has finished.

+1  A: 

you can do something like:

watch 'grep VmSize /proc/PID/status >> log'

when the program ends you'll have a list of memory footprints over time in log.

Nathan Fellman
@Nathan: thanks. BTW how can I release this command of yours at the same time "together" with my command? Such that it won't be any time lag between the two.
neversaint
your best bet is probably to have a wrapper script call the program and then run the command I suggested. You'll still have a time lag, but it'll be shorter than doing it manually
Nathan Fellman
+2  A: 

You can record it using munin + a custom plugin.

This will allow you to monitor and save the needed process information, and graph it, easily.

Here's a related answer I gave at serverfault.com

Tom Feiner
+3  A: 

Valgrind has a memory profiler called Massif that provides detailed information about the memory usage of your program:

Massif is a heap profiler. It performs detailed heap profiling by taking regular snapshots of a program's heap. It produces a graph showing heap usage over time, including information about which parts of the program are responsible for the most memory allocations. The graph is supplemented by a text or HTML file that includes more information for determining where the most memory is being allocated. Massif runs programs about 20x slower than normal.

lothar