The difference between CentOS command buffer and cache

Source: Internet
Author: User

Http://www.centoscn.com/CentOS/help/2014/1014/3940.html


A. Memory usage instructions

The free command provides a more concise view of system memory usage relative to top:

[Root@rac1 ~]# Free
Total used free shared buffers Cached
mem:1035108 1008984 26124 0 124212 413000
-/+ buffers/cache:471772 563336
swap:2096472 842320 1254152

The units shown here are KB.

In the Linux memory allocation mechanism, the first use of physical memory, when the physical memory is free (enough), it does not release its memory footprint, even if the memory-consuming program has been shut down, the program's memory used for caching, for the open program, or read just access data will be relatively fast. For the Linux memory mechanism reference:
Linux Memory mechanism
Http://blog.csdn.net/tianlesoftware/archive/2010/04/08/5463790.aspx

Mem: represents physical memory statistics.
-/+ buffers/cached: Cache statistics representing physical memory
Swap: Represents the use of swap partitions on the hard disk. Only the mem is actually occupied by the current process, that is, when there is no buffers and cache, then swap is used.

Mem Line (first row) data description:
total:1035108kb. Represents the total physical memory size.
USED:1008984KB. Represents the number of totals allocated to the cache (including buffers and cache), but some of them may not be actually used.
FREE:26124KB. Represents a memory that has not been allocated.
shared:0kb. Shared memory, not used by the general system.
buffers:124212kb. Number of buffers that are allocated but not used by the system.
cached:413000kb. Number of cache numbers that are allocated but not used by the system.

-/+ Buffers/cache Row (second row) data description:
USED:471772KB, the actual use of buffers and cache total, but also the actual amount of memory used.
FREE:563336KB, unused buffers with cache and unallocated memory, which is the system's current actual available memory.

Based on the above analysis, we can draw a conclusion:
1. Actual Available memory Size:
Free (-/+ buffers/cache line) = Free (MEM) +buffers (MEM) +cached (MEM);
563336 = 26124 + 124212+ 413000

2. Allocated Memory Size:
Used (MEM) = Used (-/+ buffers/cache) + buffers (MEM) + Cached (MEM)
1008984KB = 471772 + 124212 +413000

3. Total Physical Memory size
Total (Mem) = Used (-/+ buffers/cache) + Free (-/+ buffers/cache)
1035108 = 471772 + 563336


Two. The difference between buffer and cache
A buffer is something which has yet to be "written" to disk.
A Cache is something this has been "read" from the disk and stored for later use.

2.1 Cache
Cache: Caching is a small but high speed memory located between the CPU and the main memory.
Because the CPU speed is much higher than the main memory, CPU directly from the memory access to data to wait for a certain period of time, the cache is stored in the CPU has just been used or recycled part of the data, when the CPU again use this part of the data can be directly from the cache call, which reduces the CPU waiting time, Improve the efficiency of the system.
Cache is divided into a cache (L1 cache) and level two cache (L2 cache), L1 cache integrated in the CPU, L2 early cache is generally welded on the motherboard, are now integrated in the CPU, the common capacity of 256KB or 512KB L2 Cache.


2.2 Buffer
Buffer: A zone that is used to transmit data between devices that are not synchronized or that have different priorities. The buffer allows for less mutual waiting between processes, so that when data is read from a slow device, the operating process of the fast device does not break.

The buffer and cache displayed in the free command are all memory consuming:
Buffer: As buffer cache memory, is the block device read and write buffer, closer to the storage device, or directly is disk buffer.
Cache: As page cache memory, file system cache, is memory buffer

If the cache value is very large, indicating that the cache to live a large number of files. If frequently accessed files can be cache, then disk read IO will be very small.

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.