The difference between buffer and cache in Linux free command
~$ Free
Total used free shared buffers Cached
mem:1025204 981636 43568 0 38244 387808
-/+ buffers/cache:555584 469620
swap:1931256 162948 1768308 www.ahlinux.com
You can also see the dynamic information via $watch free
The above is the output of the free command, from which the current system memory usage can be obtained.
The system's available memory should look at the second row of data,
-buffers/cache=used-buffers-cached
+buffers/cache=free+buffers+cached
Because the first line of used contains the buffer and cache used by the system, and free does not contain buffer and cache,
This section is also part of the work that you can use.
As shown above, 555584 uses memory for a real system, while 469620 is the real available memory condition for the system.
The differences between buffer and cache are described below:
A buffer is something that have yet to being "written" to disk.
A cache is something that have been "read" from the disk and stored for later use.
Buffer:www.ahlinux.com
Buffer, a device that is used to store speed that is not synchronized, or that transmits data between devices with different priority levels
The area. Through buffers, you can reduce the number of mutual waits between processes, thus allowing the data to be read from slow devices
, there is no interruption in the operating process of the fast device.
Cache
Cache is a small but high-speed memory that sits between the CPU and the main memory. Because
The CPU is much faster than the main memory, the CPU accesses the data directly from the memory to wait for a certain period of time, the cache is saved
A portion of the data that the CPU has just used or recycled, which can be directly adjusted from the cache when the CPU uses that part of the data again
The CPU wait time, which improves the efficiency of the system. Cache is also divided into a cache (L1 cache)
and level two cache (L2 cache), the L1 cache is integrated within the CPU, and the L2 cache is usually welded to the motherboard early
are also integrated within the CPU, with a common capacity of 256KB or 512KB L2 Cache.
When you read and write files, the Linux kernel caches files in memory in order to improve read and write performance and speed.
This part of memory is the cache memory. Even after your program has finished running, the Cache memory will not
Automatically released. This will cause you to read and write files frequently in your Linux system, and you will find that there is little physical memory available.
In fact, this cache memory is automatically released when you need to use memory, so you don't have to worry about not having
Memory is available. If you want to release the cache memory manually, there is a way.
How to release the cache memory (cached RAM), use the following command to release the cache memories:
To free Pagecache
$sync; Echo 1>/proc/sys/vm/drop_caches
To free dentries and inodes:www.ahlinux.com
$sync; Echo 2>/proc/sys/vm/drop_caches
To free Pagecache, dentries and Inodes:
$sync; Echo 3>/proc/sys/vm/drop_caches
Note that it is best to sync before releasing to prevent data loss.
Buffer and cache in the free command: (they are all memory-intensive):
Buffer: Memory as buffer cache, which is the read and write buffer of the block device
Cache: As the page cache memory, the file system cache
Author Yef.zhu
- This article from: Hobby Linux Technology Network
- This article link: http://www.ahlinux.com/start/cmd/19748.html
The difference between buffer and cache in Linux free command