Get the App
SLTechnology News&Howtos  ›  Servers  › 

Linux manually releases Cache

Shulou Source: shulou.com Published: 2022-06-02 06:22:33 11月17日 Update

1. Directly change the kernel running parameters

# release pagecache

Echo 1 > / proc/sys/vm/drop_caches

# release dentries and inodes

Echo 2 > / proc/sys/vm/drop_caches

# release pagecache, dentries and inodes

Echo 3 > / proc/sys/vm/drop_caches

two。 Use sysctl to reset kernel running parameters

Sysctl-w vm.drop_caches=3

Note: both of these methods are temporary. Permanent validity needs to be added to the sysctl.conf file, which is generally written as a script to clean up manually. It is recommended not to clean up.

Modify / etc/sysctl.conf to add the following options, memory will not continue to increase

Vm.dirty_ratio = 1

Vm.dirty_background_ratio=1

Vm.dirty_writeback_centisecs=2

Vm.dirty_expire_centisecs=3

Vm.drop_caches=3

Vm.swappiness = 100

Vm.vfs_cache_pressure=163

Vm.overcommit_memory=2

Vm.lowmem_reserve_ratio=32 32 8

Kern.maxvnodes=3

The above settings are rough, making it almost impossible for cache to play its role. It is necessary to make appropriate adjustments according to the condition of the machine to find the best compromise.

Tags: Kernel parameters run manual appropriate rough two functions memory suggestions files methods machines conditions scripts faceted permanent compromise tuning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Technology Xiaomi Shulou Information Shulou Tech Info