Print RAM Usage of process including children
Prints resident set size (RAM) usage of processes including $1 in their name (includes children):
function ram() {pgrep -f $1 | xargs -I{} pmap -x {} | grep total | python -c "import sys; print('%.2f' % (sum([float([c for c in line.strip().split(' ') if c][3]) for line in list(sys.stdin)])/1024), 'MB RAM')"}
Been looking for a way to see total RAM usage of processes including their children, after a bit of googling I came up with this ugly one liner, but hey it works!
6 comments
[ 4.1 ms ] story [ 26.2 ms ] threadOne-liners are cool.
$ ram firefox
Will print total firefox RAM usage.
On my machine (Arch Linux) it works without root...
e.g.
$ pgrep -f bash | xargs -I{} pmap -x {} | grep total | awk '{sum=sum+$4}END{printf "%.2f%s", sum/1024," MB\n"}'
74.79 MB