memory usage - What do the changes in `free` output from 14.04 to 16.04 mean? - Ask Ubuntu

243 阅读2分钟
原文链接: askubuntu.com

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

           total       used       free     shared    buffers     cached
Mem:       8074640    6187480    1887160     377056     365128    2113156
-/+ buffers/cache:    3709196    4365444
Swap:     15998972      82120   15916852

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

used = total - free - cached - buffers

Previously, it used to be:

used = total - free

This change was introduced in the following commit gitlab.com/procps-ng/p…

An intermediate value:

buffers_plus_cached = buffers (kb_main_buffers) + cached (kb_main_cached) = 365128 + 2113156 = 2478284

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

buffers = kb_main_used - buffers_plus_cached = 6187480 - 2478284 = 3709196
/
cache = kb_main_free + buffers_plus_cached = 1887160 + 2478284 = 4365444

The new buff/cache value is calculates like this:

buff/cache = kb_main_buffers+kb_main_cached = 365128 + 2113156 = 2478284

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: gitlab.com/procps-ng/p… gitlab.com/procps-ng/p…

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:

Estimation of how much memory  is  available  for  starting  new
applications,  without swapping. Unlike the data provided by the
cache or free fields, this field takes into account  page  cache
and also that not all reclaimable memory slabs will be reclaimed
due to  items  being  in  use  (MemAvailable  in  /proc/meminfo,
available   on   kernels  3.14,  emulated  on  kernels  2.6.27+,
otherwise the same as free)

Courtesy: manpages.ubuntu.com/manpages/xe…

So, the specific answer to your questions would be:

  • The new version of free includes buffers/cache in the calculations of Mem used/free values.
  • 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.