By default, Linux reserves a lot of space for caching (almost all) for accelerating file IO. When a large number of reads and writes occur in the system, the page cache often consumes physical memory. although there is no danger of swap to the hard disk, it is always uncomfortable to look at the full physical memory. The kernel parameter below ensures that a portion of the physical memory is reserved without being eroded by the cache. Because the remaining memory reaches this value, the memory will be forcibly recycled. because the cache priority is low, the memory will be recycled first.
By default, Linux reserves a lot of space for caching (almost all) for accelerating file IO. When a large number of reads and writes occur in the system, the page cache often consumes physical memory. although there is no danger of swap to the hard disk, it is always uncomfortable to look at the full physical memory.
The kernel parameter below ensures that a portion of the physical memory is reserved without being eroded by the cache. Because the remaining memory reaches this value, the memory will be forcibly recycled. because the cache priority is low, the memory will be recycled first.
The default parameters are as follows:
| |
# Vm. min_free_kbytes = 67584 |
The 67584kb is converted to 66 MB, which means that the system only reserves MB of physical memory. This parameter can be expanded to make the physical memory more idle, for example, 1G idle.
| |
VMS. min_free_kbytes = 1048576 |
In my opinion, this parameter applies to applications such as file/web/cache.
Exercise caution when using a machine with high memory pressure, because OOM (out of memory, memory overflow) may occur if the cache is still insufficient after it is recycled, and serious system crashes may occur. High Memory pressure refers to the amount of memory occupied by programs, such as databases and large applications.
Generally, if the page cache of the machine occupies a large proportion, the memory pressure on the machine is not high.
There is also a kernel parameter, vm. drop_caches, default value
Optional values:
0: Do not delete
1. delete page cache
2. delete page cache and buffer cache
3. delete all caches
If this parameter is enabled, it is crude. in addition to the cache being used by the program, the other parameters are automatically deleted. It is best to manually sync and refresh dirty data to the hard disk, otherwise there may be a risk of data loss.
In contrast, vm. min_free_kbytes is more ambitious. it controls the cache size, and the cache is passively deleted.