Calculate total memory used by apps
ps aux | awk '{sum+=$6} END {print sum / 1024}’
To free pagecache:
echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
echo 3 > /proc/sys/vm/drop_caches
dd physical memory being used by a user, in this it’s user daemon
ps aux |awk '{if($1 ~ "daemon"){Total+=$6}} END {print Total/1024" MB"}'
see how many processes are using swap:
grep Swap /proc/[1-9]*/smaps | grep -v '\W0 kB'
list the top 10 processes using the most swap:
ps ax | sed "s/^ *//" > /tmp/ps_ax.output for x in $(grep Swap /proc/[1-9]*/smaps | grep -v '\W0 kB' | tr -s ' ' | cut -d' ' -f-2 | sort -t' ' -k2 -n | tr -d ' ' | tail -10); do swapusage=$(echo $x | cut -d: -f3) pid=$(echo $x | cut -d/ -f3) procname=$(cat /tmp/ps_ax.output | grep ^$pid) echo "============================" echo "Process : $procname" echo "Swap usage: $swapusage kB"; done