free命令在Ubuntu16.04之后的差别

I noticed that the  free command reporting has changed somewhere between Trusty and Xenial. Here is what `free -m’ shows on one of my Trusty computers:

Here is the equivalent on (a different) Xenial system:

The +/- buffers/cache line, which I mainly used to look at, is gone. How should I interpret the new numbers?

  • Does Mem used/free include buffers and cache or not?
  • Which numbers are the equivalent of the used and free numbers on the “+/- buffers/cache” line of the earlier version?

Please consider the sample output I got from the  free command in my  Ubuntu 12.04:

The Mem  used(kb_main_used) field value is now calculated like this:

Previously, it used to be:

This change was introduced in the following commit https://gitlab.com/procps-ng/procps/commit/6cb75efef85f735b72e6c96f197f358f511f8ed9

An intermediate value:

+/- buffers/cache value is calculated like this:

The new buff/cache value is calculates like this:

This is the same as the  buffers_plus_cached, used in previous versions, the difference is that previously it was used internally, and now its displayed directly, and the further calculated line,  -/+ buffers/cache has been removed

For more info, please check these commits, where these changes were introduced:https://gitlab.com/procps-ng/procps/commit/f47001c9e91a1e9b12db4497051a212cf49a87b1https://gitlab.com/procps-ng/procps/commit/c9908b59712d1afd6b9bf7971ba1d8900ae5adb8

As of the new  available field, for Linux kernels older than 2.6.27, its value is the same as the  free value, but for the later versions of the Kernel, its a bit different:

Courtesy: http://manpages.ubuntu.com/manpages/xenial/en/man1/free.1.html

So, the specific answer to your questions would be:

  • The new version of  free includes buffers/cache in the calculations of  Mem used/freevalues.
  • The  +/- buffers/cache value that used to be there in previous versions of  free is now available as:
    • -/+ buffers/cache  used = Current  Mem used column (Its calculation is detailed above)
    • -/+ buffers/cache  free is available as the more accurate value in the current new column  available

N.B: The  kb_* variable names are the internal names used in the source code.

 

 

 

参考链接:

https://askubuntu.com/questions/770108/what-do-the-changes-in-free-output-from-14-04-to-16-04-mean

 

 

 

 

 

 

 

 

 

 

Leave a Reply

Your email address will not be published.