Linux performance _ memory

Source: Internet
Author: User
LinuxThe difference between memory buffer and cache in the operating system is as follows: Let's start with the free command.
Compared with top, the free command provides a more concise view of the system memory usage:
$ Free
Total used free shared buffers cached Mem: 255268 238332 16936 0 85540 126384 -/+ Buffers/cache: 26408 228860 Swap: 265000 0 265000Mem: physical memory statistics
-/+ Buffers/cached: indicates the cache statistics of physical memory.
Swap: indicates the usage of swap partitions on the hard disk.
The total physical memory of the system is 255268kb (256 MB), but the actually available memory B of the system is not 16936kb In the first line, which only indicates the unallocated memory.
We use names such as total1, used1, free1, used2, and free2 to represent the values of the preceding statistics. 1 and 2 represent the data of the first and second rows respectively.
Total1: total physical memory.
Used1: indicates the total quantity allocated to the cache (including buffers and cache), but some of the caches are not actually used.
Free1: unallocated memory.
Shared1: shared memory, which is not used by the general system and is not discussed here.
Buffers1: Number of buffers allocated by the system but not used.
Cached1: Number of cache allocated by the system but not used. The difference between buffer and cache is described later.
Used2: the total amount of actually used buffers and cache, which is also the total amount of actually used memory.
Free2: The sum of unused buffers, cache, and unallocated memory, which is the actual available memory of the system.
The following equations can be sorted out:
Total1 = used1 + free1total1 = used2 + free2used1 = buffers1 + cached1 + used2free2 = buffers1 + cached1 + free1
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.
For more details, see difference between buffer and cache.
Shared Memory is mainly used in UNIXData sharing between different processes in the environment is a method of inter-process communication. Generally, applications do not apply to use shared memory, and I have not verified the impact of shared memory on the above equation. If you are interested, see: What is shared memory?
[B] What is the difference between cache and buffer? [/B]
[B] cache: high-speed cache is a memory with a small but high speed located between the CPU and the main memory. [/B] 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.
[B] Buffer: a buffer zone used to transmit data between devices with Different Storage speeds or between devices with different priorities. [/B] through the buffer, mutual waits between processes can be reduced, so that when reading data from a slow device, the operation process of the fast device is uninterrupted.
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 is 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.