Clean memory and Cache methods under Linux/proc/sys/vm/drop_caches
Frequent file access results in a significant increase in the cache usage of the system
$ free-m
Total used free shared buffers Cached
mem:3955 3926 28 0 55 3459
-/+ buffers/cache:411 3544
swap:5726 0 5726
Free memory is reduced to a few 10 megabytes and the system is running slowly
Run sync to write the contents of dirty back to the hard drive
$sync
Clean up the free cache by modifying the drop_caches of the proc system
$echo 3 >/proc/sys/vm/drop_caches
drop_caches's detailed documentation is as follows:
Writing to this would cause the kernel to drop clean caches, den Tries and inodes from memory, causing the memory to become free.
to free Pagecache:
* echo 1 >/proc/sys/vm/drop_caches
to free dentries and inodes:
* Echo 2 >/proc/sy S/vm/drop_caches
to free Pagecache, dentries and inodes:
* echo 3 >/proc/sys/vm/drop_caches
As this is a non- Destructive operation, and dirty objects is notfreeable, the user should run "sync" first in order to make sure allcached Objects is freed.
This tunable is added in 2.6.16.
Modify/etc/sysctl.conf Add the following option and no memory continues 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, so that the role of the cache is basically unable to play. It is necessary to adjust the condition of the machine to find the best compromise.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Clean memory and cache methods under Linux