In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "what is the difference between Linux memory buffer and cache". In daily operation, I believe many people have doubts about the difference between Linux memory buffer and cache. Xiaobian consulted all kinds of information and sorted out simple and easy to use operation methods. I hope to answer your doubts about "what is the difference between Linux memory buffer and cache"! Next, please follow the small series to learn together!
I. Memory Usage Notes
The Free command provides a simpler view of system memory usage than 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 unit shown here is KB.
In Linux memory allocation mechanism, priority is given to the use of physical memory, when physical memory is still free (still enough), will not release its occupied memory, even if the program has been closed, the program occupied memory used for cache use, for open programs, or read just accessed data will be faster. For 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: Indicates cache statistics for physical memory
Swap: Indicates the usage of swap partitions on the hard disk. Swap is only used when mem is actually used up by the current process, i.e. there are no buffers or caches.
Mem row (*** row) Data description:
Total:1035108KB。Represents the total physical memory size.
Used:1008984KB。Indicates the total amount allocated to cache (both buffers and cache ) use, although some of the cache may not be actually used.
Free:26124KB。Represents unallocated memory.
Shared:0kb。Shared memory, which is not normally used by systems.
Buffers:124212KB。Number of buffers allocated by the system but not used.
Cached:413000KB。Number of caches allocated by the system but not used.
-/+ buffers/cache line (second line) Data description:
Used: 471772kb, the total number of buffers and caches actually used, and also the total amount of memory actually used.
Free: 563336kb, the sum of unused buffers plus cache and unallocated memory, which is the actual memory currently available on the system.
Based on the above analysis, one conclusion can be drawn:
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
II. 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.
2.1 Cache
Cache: Cache is a small but fast memory located between CPU and main memory.
Because the CPU speed is much higher than the main memory, CPU directly access data from the memory to wait for a certain period of time, Cache stores a part of the CPU just used or recycled data, when the CPU uses this part of the data again can be directly called from the Cache, this reduces the CPU waiting time, improve the efficiency of the system.
Cache is also divided into a cache(L1 Cache) and a Cache(L2 Cache), L1 Cache integrated in the CPU, L2 Cache early is generally welded on the motherboard, now also integrated in the CPU, common capacity is 256KB or 512KB L2 Cache.
2.2 Buffer
Buffer: buffer, an area used to store data transmitted between devices with different speeds or priorities. Buffers make it possible for processes to wait less for each other, so that when data is read from a slower device, there is no interruption in the operation of a faster device.
Buffer and cache displayed in the Free command, both of which occupy memory:
buffer : memory that acts as a buffer cache, a read-write buffer for block devices, a buffer closer to storage devices, or a buffer directly for disks.
cache: memory as page cache, cache of file system, buffer of memory
If the cache value is large, it means that the cache holds a large number of files. If frequently accessed files can be cached, the read IO of the disk must be very small.
At this point, the study of "What is the difference between Linux memory buffer and cache" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.