, ,

Linux – Top memory usage by process

Here are a couple of commands to help find top memory wasters

Process – Sorted by occupied memory(2 column)


ps -e -orss=,pid=,args= | sort -nr | head|awk '{print $2"\t"$1/1024"\tMB\t"$3;}'

Method 2


cat /proc/meminfo |grep MemTotal
echo ' ' | awk '{ system("cat /proc/meminfo |grep MemTotal") }'


totalmem=$(cat /proc/meminfo |grep MemTotal | awk '{print $2}');

ps -e -orss=,pid=,args= | sort -nr | head|awk '{print $2"\t"$1/1024"\t"$3"\t"$totalmem;}'

Disk Usage – 2 Levels

a bit unrelated …


sudo du -hx --max-depth=2 / |egrep "^[0-9\.]+G"

# show home directory
echo ' ' | awk '{ system("ls -la ~") }'

References

1. http://stackoverflow.com/questions/4802481/how-to-see-top-processes-by-actual-memory-usage
2. http://stackoverflow.com/questions/131303/linux-how-to-measure-actual-memory-usage-of-an-application-or-process
3. Python Memory Profiler: http://stackoverflow.com/questions/110259/which-python-memory-profiler-is-recommended