I want to see the peak memory usage of a command
. I have a parametrized algorithm and I want to know when the program will crash due with an out of memory error on my machine (12GB RAM).
I tried:
/usr/bin/time -f "%M" command
valgrind --tool=massif command
The first one gave me 1414168
(1.4GB; thank you ks1322 for pointing out it is measured in KB!) and valgrind gave me
$ ms_print massif.out
--------------------------------------------------------------------------------
n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B)
--------------------------------------------------------------------------------
75 26,935,731,596 22,420,728 21,956,875 463,853 0
I'm a bit confused which number I should take, but let's assume "total" (22MB).
And the massif-visualizer
shows me
Now I have 3 different numbers for the same command:
valgrind --tool=massif command
+ms_print
: 22MBvalgrind --tool=massif command
+massif-visualizer
: 206MB (this is what I see inhtop
and I guess this is what I'm interested in)time -f "%M" command
: 1.4GB
Which is the number I should look at? Why are the numbers different at all?