Sort Memory Intensive Processes

This simple Linux command one-liner will give you the process name, PID, and memory usage in kb:

for file in /proc/*/status ; do awk '/^Pid|VmRSS|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 3 -n -r | less

Produces something like the following:

R 19173 8206748 kB
R 19305 7097212 kB
clamd 3786 424844 kB
fail2ban-server 3953 6180 kB
sshd 15047 4124 kB
pickup 19007 3552 kB
rsyslogd 2975 3540 kB
bash 19136 2636 kB
bash 19230 2632 kB
sshd 15050 2012 kB
bash 15051 1984 kB
hald 3534 1508 kB
screen 19229 1496 kB
screen 19135 1464 kB
bash 16751 1036 kB
awk 17399 992 kB

Useful for profiling application memory usage or killing hogs.

Leave a Reply

Your email address will not be published. Required fields are marked *