2

I ask a question, In my centos7, why available value less than free sometimes

I think available value is equal to free+buff+cache, available means when start a app how many memory can use?

[root@izuf6dbkdletdzecvyepl8z ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:            992         160         380         342         451          44
Swap:             0           0           0

   available
          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)
Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
穆阿浩
  • 401
  • 2
  • 10
  • 19

1 Answers1

0

Buffered/cached is RAM that was used by a process - say, Firefox - but the process has ended. But the system doesn't actually need that ram right now, so why flush it out? Someone may want to read that Firefox binary and associated libs back into memory... so it is kept cached in RAM until that RAM is needed by a process OR the Firefox (or whatever) binary is re-launched.

You can test this by rebooting your system, and then after your desktop has fully loaded, etc. start Firefox or Chrome or the Gimp or some other larger app, and time how long it takes. Once it is open, close it. Wait a moment or three, maybe check via ps or other utils that it is really no longer running. Then start the timer and launch it again. Much faster, yes? That is because instead of re-reading the binaries/libs back into RAM it simply re-marks the cached RAM areas as "in use".

ivanivan
  • 4,955
  • 1
    That’s not how the page cache works (or is accounted for). The binaries won’t be re-read from disk, but it’s not simply a matter of “re-marking” cache RAM as “in use”... What’s more, the cache is accounted for separately, and the fact that data is in cache should make available memory larger than free memory (see this answer for details of the calculation). – Stephen Kitt Apr 26 '18 at 12:28