PS Command Examples

Below are PS Command Examples I will try to add.

Command to the process using highest memory

You can use the below PS command with the sort option which shows the process using highest %MEM usage at the bottom.

 [root@server ~]# ps aux --sort pmem
apache   29798  1.5  6.2 570424 31116 ?        S    05:11   3:32 /usr/sbin/httpd -DFOREGROUND
apache   29831  1.5  6.4 567676 32136 ?        S    05:12   3:29 /usr/sbin/httpd -DFOREGROUND
apache   18426  0.3  6.4 562656 32404 ?        S    08:57   0:01 /usr/sbin/httpd -DFOREGROUND
apache   18364  0.5  6.5 565692 32860 ?        S    08:56   0:01 /usr/sbin/httpd -DFOREGROUND
apache   29809  1.5  6.8 567452 34336 ?        S    05:11   3:31 /usr/sbin/httpd -DFOREGROUND
apache   18356  0.4  6.9 567512 34572 ?        S    08:56   0:01 /usr/sbin/httpd -DFOREGROUND
apache   29792  1.5  7.2 569516 36144 ?        S    05:11   3:33 /usr/sbin/httpd -DFOREGROUND
apache   29825  1.4  7.4 569532 37372 ?        S    05:11   3:27 /usr/sbin/httpd -DFOREGROUND
apache   18014  0.3  8.0 570868 40232 ?        S    08:51   0:02 /usr/sbin/httpd -DFOREGROUND
apache   29791  1.5  8.2 572836 41040 ?        S    05:11   3:36 /usr/sbin/httpd -DFOREGROUND

From the example above we can see that the PID 29791 is using the highest memory. You can note the PID of the process which is using the high memory and then you can see the details using ps.

[root@server ~]# ps ev --pid=18426
  PID TTY      STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
18426 ?        S      0:03   3847   483 570652 41760  8.3 /usr/sbin/httpd -DFOREGROUND LANG=C PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin NOTIFY_SOCKET=/run/systemd/notify
[root@server ~]#

Note: In the above output, if RSS (resident set size, in KB) increases over time (so would %MEM), it may indicate a memory leak in the application.

Leave a Reply

Your email address will not be published. Required fields are marked *