How to check memory usage in Linux

1. top command:

  • input the command:

top

  • Output content display:

  • content analysis:

      PID: The ID of the process  

      USER: process owner

       PR: The priority level of the process, the smaller the priority is to be executed

       NI: Process Nice value, representing the priority value of this process

       VIRT: virtual memory occupied by the process

       RES: physical memory occupied by the process

       SHR: Shared memory used by the process

      S: The state of the process. S means sleep, R means running, Z means zombie

       %CPU: Process occupied by CPU usage

       %MEM: The percentage of physical memory and total memory used by the process

       TIME+: The total CPU time occupied by the process after it is started, that is, the cumulative value of the CPU usage time

       COMMAND: The name of the command that started the process

2. free command:

  • Enter command categories:

free Display data in KB

free -m displays data in MB

free -h display data in GB

  • Analysis of the output results:

total : total size of memory in the house

used : the size of the used memory

free : the amount of free memory

shared : total amount of memory shared by multiple processes

buff/cache : disk cache size

available : Available memory size, from the application's point of view: available = free + buff/cache .

3. cat /proc/meminfo command:

  • Enter:

cat /proc/meminfo

  • Output content analysis:

This is the easiest way to see RAM usage. This dynamically updated virtual file is actually a combination of many other memory-related tools, such as top, free, etc. listed above. It lists all the memory usage we want to know.

Process memory usage information can also be viewed through: /proc/<pid>/statm and /proc/<pid>/status.

4. ps command:

  • How to enter content:

ps aux : display content by pid (default sorting)

ps aux --sort -rss : display content sorted by rss

  • output:

5. vmstat command:

  • input the command:

vmstat -s

  • output:

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324982270&siteId=291194637