Difference between buffer and cache in linuxfree command

Source: Internet
Author: User
The difference between buffer and cache in the linuxfree command ~ $ FreetotalusedfreesharedbufferscachedMem: 1025204981636435680... information & nbsp; | & nbsp; difference between buffer and cache in linux free command ~ $ Free total used free shared buffers cachedMem: 1025204 981636 43568 0 38244 387808-/+ buffers/cache: 555584 469620 Swap: 1931256 162948 1768308 www.2cto.com you can also use $ watch free to view the dynamic information and the output content of the free command. the current system memory usage can be obtained.
The system's available memory should look at the second line of data, -buffers/cache = used-buffers-cached + buffers/cache = free + buffers + cached because the first row of used contains the buffer and cache used by the system, free does not contain buffer and cache,
This part is also usable. as shown above, 555584 shows the real memory usage of the system, while 469620 shows the real available memory usage of the system. the following describes the difference between buffer and cache: A buffer is something that has yet to be "written" to disk. A cache is something that has been "read" from the disk and stored for later use. buffer: www.2cto.com buffer, a region used to transmit data between devices with different storage speeds or 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. 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 256KB or 512KB L2 Cache. When you read and write files, the Linux kernel caches the files in the Memory to improve the read and write performance and speed. this part of the Memory is Cache Memory ). The Cache Memory will not be automatically released even after your program runs. This will cause your program to read and write files frequently in Linux, and you will find that there is very little available physical memory. In fact, this Cache Memory will be automatically released when you need to use the Memory, so you do not have to worry about no Memory available. You can also manually release the Cache Memory. Use the following command To release Cache Memory: To free pagecache $ sync; echo 1>/proc/sys/vm/drop_cachesTo free dentries and inodes: www.2cto.com $ sync; echo 2>/proc/sys/vm/drop_cachesTo free pagecache, dentries and inodes: $ sync; echo 3>/proc/sys/vm/drop_caches note, it is recommended to sync data before release to prevent data loss. Buffer and cache in the free Command: (they both occupy memory): buffer: the memory used as the buffer cache, which is the read/write buffer cache of block devices: the memory used as the page cache, file system cache author yef. zhu
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.