Home >Operation and Maintenance >Linux Operation and Maintenance >How to check memory usage of linux server
Today I will share with you the command to view the memory.
free command
(Recommended tutorial: linux tutorial)
free command displays system usage and idle Memory status, including physical memory, interactive area memory (swap) and kernel buffer memory.
It clearly shows the total memory, how much has been used, and how much is left. Here you can see that Swap's used has used 811Mb. A multi-threaded audio downloading process is running on the server. The physical memory is no longer enough, so part of the memory is virtualized from the disk. Of course, we can use free -g and free-h to view it, but the displayed memory units are different. Free -h will display the memory size in an easy-to-read unit.
Physical memory and Swap exchange area
When the physical memory is almost exhausted, the system does not crash, but uses swap as temporary memory. Both are exhausted, and the system OutofMemory
The physical memory reaches the peak. The memory occupied by some infrequently used processes in the system may be kicked to the swap area
When the resources in the Mem area are released, they are Not all the memory moved to swap will come back. It will slowly return to the mem area as the system or program wakes up.
Swap is the memory virtualized by the disk when the memory is insufficient. The disk is mainly for I/O. Level operations are not system kernel level operations, and the processing speed is not at the same level as the Mem area
shooting the first bird
Many services are generally deployed on the production environment server. When the memory is received When there is insufficient alarm, the first thing we think of is to see which process takes up the most memory. We can execute the following command. This command can check the memory usage of each process.
ps -eo pmem,pcpu,rss,args | sort -k 1 -r | less
As shown in the figure below, the first column is the percentage of memory occupied by the process. You can see which applications occupy more memory and can be used to troubleshoot problems:
top command to check memory
The top command checks the real-time load of the system, including processes, CPU load, memory usage, etc.; directly enter the top command
Related recommendations: php training
The above is the detailed content of How to check memory usage of linux server. For more information, please follow other related articles on the PHP Chinese website!