Recording Memory Footprint In Linux
Asked Answered
A

3

6

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.

Angadresma answered 2/6, 2009 at 7:27 Comment(1)
Similar question on Server Fault: serverfault.com/questions/11754/…Vicennial
N
5

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.

Nimrod answered 2/6, 2009 at 7:41 Comment(2)
@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.Angadresma
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 manuallyNimrod
T
4

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.

Teetotaler answered 2/6, 2009 at 15:22 Comment(0)
L
2

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

Lanna answered 2/6, 2009 at 7:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.