How to clear system cache in Linux

Source: Internet
Author: User
1. drop_caches

The following descriptions are available in documentation/sysctl/vm.txt:

Drop_caches

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 not freeable, the user shoshould run 'sync' first.

2. Differences between cache and Buffer
Cache: high-speed cache is a memory with a small capacity but high speed located between the CPU and the main memory. Because the CPU speed is much higher than the master memory, it takes a certain period of time for the CPU to directly access data from the memory. The cache stores part of the data that has just been used by the CPU or is used cyclically, when the CPU uses this part of data again, it can be called directly from the cache, which reduces the CPU wait time and improves the system efficiency. Cache is divided into Level 1 cache (L1 cache) and level 2 cache (L2 cache). L1 cache is integrated into the CPU, and L2 cache is usually soldered to the motherboard in the early stages, it is also integrated into the CPU. The common capacity is kb or kb.
L2 cache.
Buffer: a buffer used to transmit data between devices with Different Storage speeds or between devices with different priorities. Through the buffer zone, mutual waits between processes can be reduced, so that when reading data from a slow device, the operation process of the fast device will not interrupt.

Buffer and cache in free: (both occupy memory ):

Buffer: the memory used as the buffer cache. It is the read/write buffer of Block devices.

Cache: Memory Used as the page cache, the cache of the file system

If the cache value is large, the number of files in the cache is large. If files frequently accessed can be cached, the disk read Io BI will be very small.

 

 

 

 

 

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.