X
    Categories: Linux

4 Awesome ways to find top memory consuming processes in Linux.


In my earlier article we had discussed how to find top CPU consuming processes in Linux Now its time to find top memory consuming processes in Linux. This article will help you with how to quickly find top memory consuming processes in Linux.


1. Finding out  top memory consuming processes in Linux using ps command.

There is one liner code available with ps command which will help you  to find top memory consuming processes in Linux.

Command:

# ps -eo pid,ppid,cmd,%mem --sort=-%mem | head

Sample Output:

[root@rhel ~]# ps -eo pid,ppid,cmd,%mem --sort=-%mem | head
  PID  PPID CMD                         %MEM
 1020  1016 stress --vm 2 --vm-bytes 12 11.2
 1017  1015 stress --vm 2 --vm-bytes 12  9.6
 1019  1016 stress --vm 2 --vm-bytes 12  4.9
 1018  1015 stress --vm 2 --vm-bytes 12  2.7
  746     1 /usr/bin/python -Es /usr/sb  2.0
 1004  1002 stress --vm 2 --vm-bytes 12  1.7
  544   520 /sbin/dhclient -d -q -sf /u  1.5
  499     1 /usr/lib/polkit-1/polkitd -  0.9
  520     1 /usr/sbin/NetworkManager --  0.8
[root@rhel  ~]#

Here output get sorted according to memory utilisation which will help you find out top memory consuming processes in Linux very easily.

2. Continuously monitoring top memory consuming processes in Linux.

If in case you need to monitor the output continuously. Below command which is using watch command comes very handy.

Command:

# watch "ps -eo pid,ppid,cmd,%mem --sort=-%mem | head"

Sample output:

[root@rhel ~]# watch "ps -eo pid,ppid,cmd,%mem --sort=-%mem | head"
Every 2.0s: ps -eo pid,ppid,cmd,%mem --sort=-%mem | head                                                                                        Sun Sep 10 11:45:17 2017

  PID  PPID CMD                         %MEM
 1004  1002 stress --vm 2 --vm-bytes 12 12.9
 1003  1002 stress --vm 2 --vm-bytes 12 12.0
 1018  1015 stress --vm 2 --vm-bytes 12 10.2
 1020  1016 stress --vm 2 --vm-bytes 12  9.6
 1017  1015 stress --vm 2 --vm-bytes 12  8.0
 1019  1016 stress --vm 2 --vm-bytes 12  5.7
  746     1 /usr/bin/python -Es /usr/sb  2.0
  544   520 /sbin/dhclient -d -q -sf /u  1.5
  499     1 /usr/lib/polkit-1/polkitd -  0.9

3. Top memory consuming processes in Linux using top command.

The same output of the ps command can also be achieved using the native top command in Linux to find top memory consuming processes in Linux.

Command:

# top -o %MEM -b -n 1|head -n 12|tail -6

Sample output:

[root@rhel ~]# top -o %MEM -b -n 1|head -n 12|tail -6
  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
 1020 root      20   0  138340 131112    132 R 18.8 12.9   4:27.36 stress
 1018 root      20   0  138340  71416    132 R 18.8  7.0   4:27.36 stress
 1017 root      20   0  138340  55032    132 R 12.5  5.4   4:27.35 stress
 1004 root      20   0  138340  52404    132 R  6.2  5.2   4:36.68 stress
 1003 root      20   0  138340  27640    132 R 18.8  2.7   4:36.69 stress
[root@rhel ~]#

4. Find Top memory consuming processes in Linux using htop command.

There is one more utility called htop which will help you to find the top cpu consuming processes in Linux.  In case its not installed by default follow this article.

Command:

[root@rhel1 ~]# htop

Once you execute htop command, a continuous running window will open same like top as below:

In order to sort out the processes by memory utilisation  simply press “F6” button and then select memory and hit enter. You will able to see the processes sorted according to memory utilisation as below:

Now Learn Linux in 5 Days!!!!

Download This Book: Click Here!!

View Comments (0)

Related Post