Clean memory and cache methods under Linux

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.