CentOS Cleanup Memory Cache

Source: Internet
Author: User

When reading and writing files, the Linux kernel caches files in memory for increased read and write efficiency and speed, which is the cache memory.
The Cache memory will not be released automatically even after the program has finished running. This causes the program to read and write files frequently, with little physical memory available.
In fact, this cache memory is automatically released when you need to use memory, so you don't have to worry about not having memory available.
If you want to release the cache memory manually, there is a way.

Official documentation for cleaning up the cache (drop_caches): Http://www.kernel.org/doc/Documentation/sysctl/vm.txt

==============================================================
Drop_caches

Writing to this would cause the kernel to drop clean caches, as well as
Reclaimable slab objects like dentries and Inodes. Once dropped, their
Memory becomes free.

To free Pagecache:
Echo 1 >/proc/sys/vm/drop_caches
To free reclaimable slab objects (includes dentries and inodes):
Echo 2 >/proc/sys/vm/drop_caches
To free slab objects and Pagecache:
Echo 3 >/proc/sys/vm/drop_caches

This is a non-destructive operation and would not be free any dirty objects.
To increase the number of objects freed by this operation, the user may run
' Sync ' prior to writing to/proc/sys/vm/drop_caches. This would minimize the
Number of dirty objects on the system and create more candidates to be
Dropped.

This file was not a means to control the growth of the various kernel caches
(Inodes, Dentries, Pagecache, etc ...) These objects is automatically
Reclaimed by the kernel when memory was needed elsewhere on the system.

Use of the This file can cause performance problems. Since it discards cached
objects, it may cost a significant amount of I/O and CPU to recreate the
Dropped objects, especially if they were under heavy use. Because of this,
Use outside of a testing or debugging environment are not recommended.

Informational messages in your kernel log when the This file is
Used:
Cat (1234): Drop_caches:3

These is informational only. They do not mean the anything is wrong
With your system. To disable them, echo 4 (bit 3) into drop_caches.
==============================================================
#cat/proc/sys/vm/drop_caches
0//default is 0;1-empty page cache; 2-empty inode and directory tree cache; 3-Clear all caches
[Email protected] ~]#SyncNote: Use the sync command to synchronize data to disk before emptying the cache
[Email protected] ~]#free-m
Total used free shared buffers Cached
mem:15898 3029 12869 0 1911064
-/+ buffers/cache:1772 14125
swap:31999 0 31999
[Email protected] ~]#Echo 3>/proc/sys/vm/drop_caches
[Email protected] ~]#free-mThe discovery cache is significantly reduced
Total used free shared buffers Cached
mem:15898 1770 14128 0 1 -
-/+ buffers/cache:1738 14160
swap:31999 0 31999

CentOS Cleanup Memory Cache

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.