Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add two neat little scripts that track memory consumption of an app v…

…ia pmap

usage: track_memory.sh $(pidof someapp)
when someapp quits, it shows the memory evolution in gnuplot

you can re-create the plot using
show_memory.sh mem.log.$pid
  • Loading branch information...
commit 2601ebfef84eb1e1795de8e4c57c8dac7c43cded 1 parent 9cf35f9
@milianw authored
Showing with 30 additions and 0 deletions.
  1. +13 −0 show_memory.sh
  2. +17 −0 track_memory.sh
View
13 show_memory.sh
@@ -0,0 +1,13 @@
+logfile=$1
+
+# total:
+# '$logfile' using 3 w lines title 'Kbytes', \
+
+gnuplot -p -e "
+set xlabel 'snapshot ~1s';
+set ylabel 'memory consumption in kB';
+set key bottom right;
+plot \
+ '$logfile' using 4 w lines title 'RSS', \
+ '$logfile' using 5 w lines title 'Dirty';
+";
View
17 track_memory.sh
@@ -0,0 +1,17 @@
+pid=$1
+
+if [[ "$(ps -p $pid | grep $pid)" == "" ]]; then
+ echo "cannot find program with pid $pid"
+ exit
+fi
+
+logfile=mem.log.$pid
+
+while [[ "$(ps -p $pid | grep $pid)" != "" ]]; do
+ echo "snapshot " $pid
+ pmap -x $pid | grep total >> $logfile
+ sleep 1;
+done
+
+echo "done tracking, visualizing"
+$(dirname $0)/show_memory.sh "$logfile"
Please sign in to comment.
Something went wrong with that request. Please try again.