The correct way to read the free command

Source: Internet
Author: User

About the parameters of free command There is a lot of information on the web, so let's take a look at the correct way of interpreting it.
Now there are two versions of the free command on Linux, such as CentOS 6 with an older version, CentOS 7 with a new version, as follows
CentOS 6 :

[Root@centos-6-2 ~]# uname-r
2.6.32-573.22.1.el6.x86_64

[root@centos-6-2 ~]# free
             total       used       Free     shared    buffers     cached
Mem:       1906904     168440    1738464       3280       6916      47040
-/+ buffers/cache:     114484    1792420 
Swap:      1048572          0    

CentOS 7 :

root:~/# uname-r
3.10.0-514.26.2.el7.x86_64

root:~/# free
              total        used        free      shared  buff/cache   available
Mem:         999948      168956      451588      31848 379404 618400
Swap:       4063228           0     4063228
old version free

The previous free command (CENTOS6) has three lines: mem,-/+ Buffers/cache,swap, which represents the following:

name the content of the Representative
Mem Physical memory
-/+ Buffers/cache Indicates how much physical memory is used and how much is available
Swap Swap space

The contents of the column are total,used,free,shared,buffers,cached, and the representative's contents are as follows:

name the content of the Representative
Total Total
Used That you have used
Free of free
Shared Shared, in Linux there are a lot of shared memory, such as a libc library, many program calls, but actually save one
Buffers caching, recyclable
Cached caching, recyclable

Here's a place to be aware of the difference between buffers and cached. Cached and buffers can both read and write, the only difference is a bare device or partition as the background, a file system in the background. For example, you cat/dev/sda1 >/dev/null, that/dev/sda1 content into buffers, if you cat/opt/test.py >/dev/null, then/opt/test.py content into cached.

Look at the calculation formula for total of mem and swap
Total = used + free

For example, in this case, the used of Mem is 168440,free is 1738464, which adds up to just 1906904 of total.

Next look at the middle-/+ buffers/cache used and how free is calculated.
The used of-/+ Buffers/cache = The used of the first line-the buffers of the first line-the cached of the first row

For example, in this case, the used of-/+ Buffers/cache is 114484, which is the used 168440 of the first row, minus the buffers 6916 of the first row, and minus the cached 47040 of the first row.

-/+ Buffers/cache free = The first line of Free + the first line of buffers + the first row of cached

For example,-/+ Buffers/cache's free is 1792420, which is the first line of free 1738464, plus the first row of buffers 6916, plus the first row of cached 47040

When estimating idle physical memory, you can refer to the value of-/+ Buffers/cache free, but the actual available memory is less than this value, because not all buffers and cached are released. New Free

The new version of free compared to the old version, deleted-/+ Buffers/cache This line of content, put buffers and cached together, added available value.
Through the analysis just now can see this change more reasonable, because Buffe and cache essence is the same, there is no need to distinguish.
When viewing available memory, look directly at the available, no more calculations are required.
available = Free + (Buff/cache the value produced by an algorithm)
See the kernel's commit in detail
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773

Reference:
https://blog.csdn.net/jus3ve/article/details/79191634

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.