Free command (buffer and cache)

Source: Internet
Author: User

A. Free command[[Email Protected]_202_12/]# free-m Total used free shared buffers Cached mem:3072 2459 612 0 207 1803-/+ buffers/cache:447 2624Swap: 1913 0 1913 Line 2nd: Total Memory: 3072used The number of memory used: 2459free free Memory: 612shared is now obsolete no, always 0buffers:buffer C Ache Memory: 13220cached:page cache Memory: 2720160 relationship: total = used + Free Line 3rd:The meaning of-/+ Buffers/cache: -buffers/cache Memory: 447 (equals 1th row of used-buffers-cached) +buffers/cache Memory: 2624 (equals 1th line of Free + buffers + cached)Note: The amount of memory here is a little bit out of size after calculating it with the above formula (you don't know what the reason is). The visible-buffers/cache reflects the memory that is actually eaten by the program, and +buffers/cache reflects the total amount of memory that can be appropriated. Line 4th is separate for the swap partition.
In order to improve disk access efficiency, Linux has done some careful design, in addition to the Dentry cache (for VFS, speed up the file path name to Inode conversion), but also adopted two main cache methods: Buffer cache and Page The cache is read-write to the disk block, the latter for the file inode. These caches effectively shorten the time for I/O system calls (such as read,write,getdents).
The difference between the used/free of Line 2nd (MEM) and the 3rd line (-/+ buffers/cache) Used/free: The difference between the two is the angle of use. Line 2nd is from the OS point of view, because for os,buffers/cached all belong to being used, So his available memory is 612MB, and the memory used is 2059MB, which includes, the kernel (OS) used by +application (X, oracle,etc) +buffers+ Cached. Line 3rd refers to the application perspective, buffers/cached is available for applications, because buffer/cached is designed to improve the performance of file reads, and when the application uses memory, buffer/ Cached will soon be recycled. So from the application's point of view, available memory = System free memory+buffers+cached. As in the example above: 2624 = 612+207+1803 second, the difference between buffers and cached:Buffers is the buffer size used to make a block device, and he only records the file system's metadata and tracking in-flight pages. cached is used to buffer files. That is, buffers is used to store content, permissions, and so on in the directory, and cached is used to remember the files we open. If you want to know if he is really in effect, you can try it and execute two orders #man kill, you can obviously feel that the second time is much faster. Experiment: Doing something on a machine with no application can be seen more clearly. Remember that the experiment can only be done once, if you want to do more please change a file name. #free #man Kill#free#man Kill#free Compare the size of the buffers shown in the free. Another experiment: #free #ls/dev#free Compare the size of two, of course, this buffers is increasing at any time, but there is LS over the words, increase the speed will become faster, this is buffers/chached difference.
Because Linux uses temporarily unused memory as a file and data cache to improve system performance, the system is automatically freed when the application needs these memory (unlike Windows, even if you have a lot of free memory, he will have access to the pagefiles on the disk)
memory Exchange conditions and methods:When the available memory is less than the rated value, the exchange begins. How to look at the rating (RHEL4.0) #cat the/proc/meminfo Exchange will reduce the number of physical pages used in the system by three channels: 1. Reduce the buffer and page cache size; 2. Swap the memory page of the System V out of support; 3. Swap out or discard the page. (Application occupies a memory page, that is, insufficient physical memory). In fact, a small amount of swap usage does not affect system performance.

From for notes (Wiz)

Free command (buffer and cache)

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.