| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# a quick check for memory leak |
| 4 |
# |
| 5 |
# usage: |
| 6 |
# (../src/wrapper mol1-manual-loop.in &) ; ./mem.sh |
| 7 |
|
| 8 |
PID=`/usr/bin/pgrep -x wrapper` |
| 9 |
|
| 10 |
LOG="memusage.txt.${PID}" |
| 11 |
|
| 12 |
echo "# ElapsedTime VmSize VmRSS" > $LOG |
| 13 |
echo "# " `date` >> $LOG |
| 14 |
|
| 15 |
# seconds |
| 16 |
PERIOD=0.1 |
| 17 |
counter=0.0 |
| 18 |
|
| 19 |
status_file=/proc/${PID}/status |
| 20 |
|
| 21 |
echo "wrapper PID: $PID" |
| 22 |
|
| 23 |
while [ -e $status_file ] ; do |
| 24 |
VM_SIZE=`awk '/VmSize/ {print $2}' < $status_file` |
| 25 |
VM_RSS=`awk '/VmRSS/ {print $2}' < $status_file` |
| 26 |
echo "$counter $VM_SIZE $VM_RSS" >> $LOG |
| 27 |
sleep $PERIOD |
| 28 |
counter=`echo $counter + $PERIOD|bc` |
| 29 |
VM_SIZE="" |
| 30 |
VM_RSS="" |
| 31 |
done |
| 32 |
|
| 33 |
echo "$0 script finished ..." |
| 34 |
|
| 35 |
/usr/bin/gnuplot -persist <<EOF |
| 36 |
#set xdata time |
| 37 |
#set timefmt "%H:%M:%S" |
| 38 |
set xlabel "time (s)" |
| 39 |
set ylabel "memory (kB)" |
| 40 |
plot "$LOG" using 1:2 w l t "vm size" , \\ |
| 41 |
"$LOG" using 1:3 w l t "vm rss" |
| 42 |
EOF |
| 43 |
|