The difference between buffer and cache

Source: Internet
Author: User

1. The difference between buffer and cache

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/8B/64/wKiom1hL2fuxvFDCAAA4AR6R74E921.png-wh_500x0-wm_3 -wmp_4-s_199177087.png the difference between the "title=" buffer and the cache. png "alt=" wkiom1hl2fuxvfdcaaa4ar6r74e921.png-wh_50 "/>

The difference between buffer and cache buffer is different from the object that the cache operates on.
1) buffer (buffer) is designed to increase the speed of data exchange between memory and hard disk (or other I/O devices).

2) cache (cache) is designed to increase the speed of data exchange between CPU and memory, which is the usual first level cache, level two cache, and level three cache. The instructions and read data used by the CPU in executing the program are for memory, which is obtained from memory. Due to the slow memory read and write, in order to improve the speed of data exchange between the CPU and memory, the cache is increased between the CPU and memory, it is faster than memory, but the cost is high, and because the CPU can not integrate too many integrated circuits, so the general cache is relatively small, After Intel and other companies in order to further improve the speed, but also increased the level two cache, or even the three cache, it is based on the local principle of the program design, is the CPU execution of instructions and access to the data is often in a certain piece of the concentration, so put this piece of content into the cache, The CPU does not have to access the memory, which increases the speed of access. Of course, if the cache does not have the content required by the CPU, or access to memory.
Buffer (buffers) is based on the disk read-write design, the decentralized write operations centralized, reduce disk fragmentation and hard disk repeatedly seek, thereby improving system performance. Linux has a daemon that periodically empties the buffered content (that is, writes to disk) or manually empties the buffer via the Sync command.
In a nutshell, buffer is about to be written to disk, and the cache is read from disk. Buffer is allocated by various processes and is used in areas such as input queues. A simple example is when a process requires multiple fields to be read, and before all fields are read into full, the process saves the previously read-in fields in buffer.
The cache is often used on disk I/O requests, and if more than one process accesses a file, the file is made into a cache for next access, which improves system performance.

3) Summary:
The data is written to the memory space, which is buffer buffers, write buffers
Read the data from the memory space, this space is the buffer cache, read the buffer


2. How can I calculate the available memory in Linux?
Linux is the use of memory principles as much as possible, memory will be the remaining space to apply for the cache, and the cache is not a free, when the system is running for a long time, we will find the cache is very large, this is the reason
Note that when we see the system memory usage is very high, free is almost 0 o'clock, does not mean that the system memory capacity bottleneck! Only the system has fully played the role of memory. When a process needs to request large file memory, the kernel reclaims some of the cache space, and the reclaimed memory is then allocated to the process program for use.
[Email protected] ~]# free-h
Total used free shared buffers Cached
mem:474m 459M 14M 228K 24M 285M
-/+ buffers/cache:149m 324M
swap:767m 2.6M 765M
Available memory = Free + buffer + cache
Memory Availability =1-(buffer used/total) =1-(149/474) =69%
Instead of: 14/474=3%

This article is from the "Hyun-dimensional" blog, please be sure to keep this source http://xuanwei.blog.51cto.com/11489734/1881526

The difference between buffer and cache

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.