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
|
# ps -eo pid,ppid,cmd,%mem --sort=-%mem | head
MEM
11.2
9.6
4.9
2.7
2.0
1.7
1.5
0.9
0.8
#
|
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
|
|
Sample output:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
2017
MEM
12.9
12.0
10.2
9.6
8.0
5.7
2.0
1.5
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
|
# top -o %MEM -b -n 1|head -n 12|tail -6
COMMAND
stress
stress
stress
stress
stress
#
|
for cpu top - Command:
|
1
|
# top -b -n 1 | head -n 12 | tail -n 6
|
Sample output:
|
1
2
3
4
5
6
7
8
|
top -b -n 1 | head -n 12 | tail -n 6
COMMAND
dd
top
init
kthreadd
0
#
|
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
|
# 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: