Categories

How to find which process is eating RAM in Linux

Written by Guillermo Garron .
Date: 2010-12-07 16:50:30 -0400

Introduction

If you are running out of RAM on your Linux system, you will want to find the culprit in order to solve the problem, either by reconfiguring the RAM-hungry application or by stopping it.

We’ll use ps, awk, head and sort with a pipe, to find out which application is consuming our RAM

List running processes ordered by RAM usage

ps aux | awk '{print $2, $4, $11}' | sort -k2rn | head -n 20

PID %MEM COMMAND
3349 9.3 /usr/bin/X
3815 6.0 /usr/lib/iceweasel/firefox-bin
3750 1.0 gnome-panel
3753 0.9 nautilus
2751 0.8 /usr/sbin/mysqld
2969 0.8 /usr/bin/polipo
6129 0.7 gnome-terminal
3804 0.6 /usr/lib/gnome-applets/mixer_applet2
3772 0.6 update-notifier
3727 0.6 gnome-settings-daemon
3771 0.5 gnome-power-manager
3117 0.4 /usr/sbin/asterisk
3765 0.4 bluetooth-applet
3433 0.3 /usr/sbin/apache2
4218 0.3 /usr/lib/notification-daemon/notification-daemon
3749 0.3 /usr/bin/openbox
3604 0.3 gnome-session
3128 0.2 /usr/sbin/hald
3721 0.2 /usr/lib/libgconf2-4/gconfd-2

This will list the first 20 applications in reverse order, from the one using more RAM to the one using lest RAM.

You can also use htop or top commands, and hit M (uppercase m) to sort all processes by RAM usage.

permalink

If you enjoyed the article, please share it

twitter | facebook | google+ | linkedin | email | reddit