How to clean up memory and Cache in Linux

Source: Internet
Author: User
Article Title: how to clean up memory and Cache in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Frequent file access will increase the system Cache usage.

$ Free-m

Total used free shared buffers cached

Mem: 3955 3926 28 0 55 3459

-/+ Buffers/cache: 411 3544

Swap: 5726 0 5726

The free memory is reduced to dozens of megabytes, and the system runs slowly.

Run sync to write dirty content back to the hard disk

$ Sync

Clear free cache by modifying drop_caches of proc System

$ Echo 3>/proc/sys/vm/drop_caches

Drop_caches detailed documentation is as follows:

Writing to this will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free.

To free pagecache:

* Echo 1>/proc/sys/vm/drop_caches

To free dentries and inodes:

* Echo 2>/proc/sys/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 are notfreeable, the user shoshould run "sync" first in order to make sure allcached objects are freed.

This tunable was added in 2.6.16.

After you add the following options to/etc/sysctl. conf, the 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, so that the role of the cache is basically not available. You need to make appropriate adjustments based on the machine's conditions to find the best compromise.

Reprinted from: http://bbs.unixall.com/thread-1012-1-1.html

Related Article

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.