The difference between memory buffer and cache in Linux OS

Source: Internet
Author: User
Tags file system memory usage

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

$ free

Total used free shared buffers Cached

mem:255268 238332 16936 0 85540 126384

-/+ buffers/cache:26408 228860

swap:265000 0 265000

Mem: represents physical memory statistics

-/+ buffers/cached: Cache statistics representing physical memory

Swap: Represents the use of swap partitions on the hard drive, where we don't care.

Total physical memory for the system: 255268Kb (256M), but the system's currently available memory B is not 16936Kb of the first free tag, it represents only unallocated memory.

We use names such as Total1, Used1, Free1, Used2, and free2 to represent the values of the above statistics, and 1, 2 represent the data for the first and second rows, respectively.

Total1: Represents the total amount of physical memory.

Used1: Represents the number of total allocations to the cache (including buffers and cache), but some of them may not be actually used.

FREE1: Memory not allocated.

SHARED1: Shared memory, the general system is not used, this is not discussed here.

BUFFERS1: Number of buffers that are allocated but not used by the system.

CACHED1: Number of cache numbers that are allocated but not used by the system. The difference between buffer and cache is seen in the back.

USED2: The actual use of buffers and cache total, but also the actual amount of memory used.

Free2: Unused buffers with cache and unallocated memory, which is the system's current actual available memory.

You can sort out the following equation:

Total1 = used1 + free1total1 = used2 + free2used1 = buffers1 + cached1 + used2free2 = buffers1 + cached1 + free1

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.

More detailed explanation reference: Difference Between Buffer and Cache

For shared memory, which is primarily used to share data among different processes in a UNIX environment, is a way to communicate between processes, and the general application does not request shared memory, nor does the author verify the effect of shared memory on the above equation. If you are interested, please refer to: What is Shared Memory?

The difference between cache and buffer:

Cache: Caching is a small but high speed memory located between the CPU and the main memory. [/b] 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 used this part of the data can be directly from the cache call, which reduces the CPU waiting time , and 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.

Buffer: A zone that is used to transmit data between devices that are not synchronized or that have different priorities. [/b] through a buffer, you can reduce the mutual waiting between processes so that when data is read from a slow device, the operating process of the fast device does not break.

Buffer and cache in free: (they all occupy memory):

Buffer: As buffer cache memory, is the block device read and write buffers

Cache: As page cache memory, file system cache

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.

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.