Linux memory management and monitoring and performance evaluation

1. Linux memory management

1. Physical memory and virtual memory

Physical memory is the memory size provided by the system hardware. It is real memory. Compared with physical memory, there is a concept of virtual memory under Linux. Virtual memory is a strategy proposed to meet the shortage of physical memory. It uses disk space A piece of logical memory that is virtualized, and the disk space used as virtual memory is called swap space (Swap Space)

Linux's memory management adopts the paging access mechanism. In order to ensure that the physical memory can be fully utilized, the kernel will automatically swap the infrequently used data blocks in the physical memory to the virtual memory at an appropriate time, and the frequently used data blocks Information is persisted to physical memory.

The Linux system performs page swapping operations from time to time to keep as much free physical memory as possible.

Linux performs page swapping conditionally, not all pages are swapped to virtual memory when not in use.

The pages of the swap space will be swapped to the physical memory first when they are used. If there is not enough physical memory to hold these pages at this time, they will be swapped out immediately. Therefore, there may not be enough space in the virtual memory to store these swaps. page, which will eventually lead to problems such as false crashes and service exceptions in Linux.

2. Memory monitoring

free monitor memory: 

[root@localhost ~]# free
                          total        used              free      shared   buffers   cached
Mem:         16402432    16360492      41940        0        465404   12714880
-/+ buffers/cache:        3180208   13222224
Swap:        8193108        264      8192844

From the point of view of the kernel

Guess you like

Origin blog.csdn.net/qq_35029061/article/details/131951647