4 Awesome ways to find top memory consuming processes in Linux.
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:
|
1
|
# ps -eo pid,ppid,cmd,%mem --sort=-%mem | head
|
Sample Output:
|
1
2
3
4
5
6
7
8
9
10
11
12
|
[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:
|
1
|
# watch "ps -eo pid,ppid,cmd,%mem --sort=-%mem | head"
|
Sample output:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[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:
|
1
|
# top -o %MEM -b -n 1|head -n 12|tail -6
|
Sample output:
|
1
2
3
4
5
6
7
8
|
[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 ~]#
|
for cpu top - Command:
|
1
|
[root@rhel1 ~]# top -b -n 1 | head -n 12 | tail -n 6
|
Sample output:
|
1
2
3
4
5
6
7
8
|
[root@rhel1 ~]# top -b -n 1 | head -n 12 | tail -n 6
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
23236 root 20 0 102m 672 568 R 100.0 0.0 12:43.07 dd
23377 root 20 0 15084 1184 848 R 2.0 0.0 0:00.01 top
1 root 20 0 19396 1532 1228 S 0.0 0.0 0:01.34 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
3 root RT 0 0 0 0 S 0.0 0.0 0:05.08 migration/0
[root@rhel1 ~]#
|
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:
|
1
|
[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:



浙公网安备 33010602011771号