Skip to content

Instantly share code, notes, and snippets.

@nickleefly
Last active December 14, 2015 10:09
Show Gist options
  • Save nickleefly/5069647 to your computer and use it in GitHub Desktop.
Save nickleefly/5069647 to your computer and use it in GitHub Desktop.
check memory usage, including RSS PageTables SlabInfo
#/bin/bash
for PROC in `ls /proc/|grep "^[0-9]"`
do
if [ -f /proc/$PROC/statm ]; then
TEP=`cat /proc/$PROC/statm | awk '{print ($2)}'`
RSS=`expr $RSS + $TEP`
fi
done
RSS=`expr $RSS \* 4 / 1024`
PageTable=`grep PageTables /proc/meminfo | awk '{print $2 / 1024}'`
SlabInfo=`cat /proc/slabinfo |awk 'BEGIN{sum=0;}{sum=sum+$3*$4;}END{print sum/1024/1024}'`
echo $RSS"MB", $PageTable"MB", $SlabInfo"MB"
printf "rss+pagetable+slabinfo=%sMB\n" `echo $RSS + $PageTable + $SlabInfo|bc`
free -m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment