cancel
Showing results for 
Search instead for 
Did you mean: 
jeesshnasree
Starfighter Starfighter
Starfighter
  • 11.2K Views

how to find process memory usage from RAM in linux

Jump to solution

Hello All,

 

Please find my questions and proivde me your valuable suggestions/help/guidance .

if any difference like dependency like OS version for execute command then please specify the command . its for me learning and some doubts that reason posting here .  I hope you understand about my intensions. 

OS : Linux OS (RHEL/CentOS)

 

Question 1:

How to know , which process consuming memeory in the RAM in Linux OS.

How much using and available . 

 

example:

in my Linux OS box :

up and running tomcat and apache web servers .

how to find out tomcat/java processor consuming the RAM .

How to calculate each process if running memory details in RAM .

Please check and provide detailed information .

I am waiting for your valuable reply .

Question 2:

I tried to use top command memory usage details with Gb using E option able to see but same OS other box'es unable to see .

how to read top command memeory in human readable format , if any command  is there then please share to check .

 

 

please find one sample:

top - 14:14:36 up 1:09, 3 users, load average: 0.00, 0.04, 0.06
Tasks: 356 total, 1 running, 355 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 6.7 sy, 0.0 ni, 93.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 3887.4 total, 1065.9 free, 2073.4 used, 1051.6 buff/cache
MiB Swap: 10240.0 total, 10240.0 free, 0.0 used. 1814.0 avail Mem

 

===========

I entered top command then get above mentioned output .

 

 

actually my question is how to get human readable format of "MiB" information on top command details .

 

Please check and provide if any command on terminal get output directly like "free -h" for top command .

if its there then please share the command . if no command like "free -h" command for top then please ignore this question.

 

 

Thanks and Regards,

Jeesshansree

1 Solution

Accepted Solutions
Chetan_Tiwary_
Community Manager
Community Manager
  • 11.1K Views

Hello @jeesshnasree !

Memory statistics in MiB is also human readable. If you specifically want top to give you that statistics in GiB then do :

#top

then press shift+e 

Chetan_Tiwary__0-1695837278193.png

To sort the  top output by memory utilisation : press M :

Chetan_Tiwary__1-1695837560649.png

For getting info of processes consuming the RAM , check these fields in top :

Chetan_Tiwary__2-1695837696092.png

Refer man page of top for the definition of these values :

Chetan_Tiwary__3-1695837769739.png

%MEM: The percentage of the physical memory the process is using.

VIRT: This is the Virtual Memory Size of the process. Virtual memory is the total physical and swap memory used by the process.

RES: This is the Resident Memory Size of the process. The resident memory is the amount of physical memory the process is using.

SHR: This is the Shared Memory Size of the process. This is the amount of memory that the process is using that is also shared with some other processes.

Use CLI tool - ps  to get the same memory utilisation :

Chetan_Tiwary__4-1695838760714.png

This is a general overview and should not be a 100% accurate measurement of RAM usage , eg. RSS value doesn’t take into account libraries already loaded in memory.

View solution in original post

8 Replies
Chetan_Tiwary_
Community Manager
Community Manager
  • 11.1K Views

Hello @jeesshnasree !

Memory statistics in MiB is also human readable. If you specifically want top to give you that statistics in GiB then do :

#top

then press shift+e 

Chetan_Tiwary__0-1695837278193.png

To sort the  top output by memory utilisation : press M :

Chetan_Tiwary__1-1695837560649.png

For getting info of processes consuming the RAM , check these fields in top :

Chetan_Tiwary__2-1695837696092.png

Refer man page of top for the definition of these values :

Chetan_Tiwary__3-1695837769739.png

%MEM: The percentage of the physical memory the process is using.

VIRT: This is the Virtual Memory Size of the process. Virtual memory is the total physical and swap memory used by the process.

RES: This is the Resident Memory Size of the process. The resident memory is the amount of physical memory the process is using.

SHR: This is the Shared Memory Size of the process. This is the amount of memory that the process is using that is also shared with some other processes.

Use CLI tool - ps  to get the same memory utilisation :

Chetan_Tiwary__4-1695838760714.png

This is a general overview and should not be a 100% accurate measurement of RAM usage , eg. RSS value doesn’t take into account libraries already loaded in memory.

jeesshnasree
Starfighter Starfighter
Starfighter
  • 11K Views

Hello @Chetan_Tiwary_ ,

 

 

Shift +e is working some systems & some hostnames its working . 

Please check & provide : one line command on terminal for Top command memory human readable format like Mega/Giga . if possiible please share command . I hope clearly explain about my doubt . thank you for share the details .

 

 

Thanks and Regards,

Jeesshansree

0 Kudos
Elankumaran
Mission Specialist
Mission Specialist
  • 11K Views

Hi @jeesshnasree,

Try out htop command, it's an improved version of the top command with much user-friendliness and mouse interactive.

 

jeesshnasree
Starfighter Starfighter
Starfighter
  • 10.5K Views

Hello @Chetan_Tiwary_ ,

 

 

Thank you so much

0 Kudos
jeesshnasree
Starfighter Starfighter
Starfighter
  • 10.5K Views

Hello @Chetan_Tiwary_ ,

 

Please check  below screenshot & provide guidance ( reason is free memeory  0) .

Mentioned example screenshot : In the machine some process are running then free memory is 0 buff/cache utilization is more . 
How to troubleshoot this issue . Please provide me if any guidance .

Any suggestions about below mentioned example :

jeesshnasree_0-1706076368997.png


Thanks and Regards,

Jeesshansree

0 Kudos
Fran_Garcia
Starfighter Starfighter
Starfighter
  • 10.4K Views
0 Kudos
Lisenet
Starfighter Starfighter
Starfighter
  • 10.9K Views

The ps command can be used to display information about processes that use the most memory resources. Compared with top, which gives a dynamic real-time view of system resources, ps reports a snapshot of the currently running processes.

$ ps -eo pid,user,s,comm,size,vsize,rss --sort -size | head
  PID USER     S COMMAND          SIZE    VSZ   RSS
 3059 mysql    S mysqld          330000 343552 172724
 2041 root     S nessusd         326112 333348 114108
 2297 bind     S named           42920  52976  1440
11763 www-data S apache2         26324 108256 27168
 2067 root     S rsyslogd        25452  28208  1092
 3547 www-data S zmfilter.pl     18900  29360  2348
11770 www-data S apache2         16676  98608 18132
11769 www-data S apache2         16380  98312 12880
11768 www-data S apache2         16128  98060 13284

Parameters used are as follows:

  1. -e: select all processes.
  2. -o: specify user-defined format.
  3. pid: process ID.
  4. user: user name.
  5. s: minimal state display (one character).
    1. S for sleeping (idle).
    2. R for running.
    3. D for disk sleep (uninterruptible).
    4. Z for zombie (waiting for parent to read it’s exit status).
    5. T for traced or suspended (e.g by SIGTSTP).
    6. W for paging.
  6. comm: command name (only the executable name).
  7. size: memory size in kilobytes.
  8. vsize: total VM size in kilobytes.
  9. rss: resident set size, the non-swapped physical memory that a task has used .
  10. –sort -size: sort size in descending numerical order.
0 Kudos
jeesshnasree
Starfighter Starfighter
Starfighter
  • 10.5K Views

Hello @Lisenet ,

 

Thank you so much .

0 Kudos
Join the discussion
You must log in to join this conversation.