Friday, June 28, 2013

Linux, Who eaten up my memory?

Linux, Who eaten up my memory?

if you want to know which PID that chewing up your memory and not letting go? Here is the small bash script.

#!/bin/bash
echo
for pid in `grep -i VmSize /proc/*/status | sort -k +2n | tail -n10 | awk -F"/" '{print $3}'`
do
        echo "************************"
        echo "PID: $pid"
        echo "Allocated memory: `grep VmSize /proc/$pid/status | awk -F":" '{print $2" "$3}'`"
        echo `ps -aef | grep $pid | grep -v grep`

done
echo

No comments: