Skip to main content
The 2024 Developer Survey results are live! See the results
2 of 10
actually answering the question
tukan
  • 6.2k
  • 8
  • 21

First I would pickup the process with the smem. For example, you could use smem -tas uss to have an overview. -t ... shows totals -a ... auto adjusts the column width -s uss... sorts the result based on the uss column

To see details per process the best way is to use pmap. To get detailed information you should use -X switch. To get all information that kernel provides you can use -XX which usually is an overkill.

To get a 2 seconds refresh monitoring for a pid 3120:

watch -n 2 pmap -X 3120

Edit: To actually get a peak The above helps in monitoring, but it does not show an actual peak. Slipped my mind.

I would personally use valgrind with the massif tool.

valgrind --tool=massif --page-as-heap=yes --massif-out-file=evolution_massif.out evolution; grep mem_heap_B evolution_massif.out | sed -e 's/mem_heap_B=\(.*\)/\1/' | sort -g | tail -n 1

Explanation: --page-as-heap=yes ... tells massif that it should take all memory instead of just heap --massif-out-file ... the output file for the massif tool evolution ... the application that should be monitored

The next part is there to find out the maximum number recorded.

The grep searches for mem_heap_B occurrences. sed gets rid of the string mem_heap_B so we get only numeric result. The we sort it via sort -g which is generic numeric sort and take the biggest number with tail -n 1 which returns the first line of the sorted numbers.

tukan
  • 6.2k
  • 8
  • 21