计算liunx中的可用内存

计算liunx中的可用内存

执行:-

free -k

给出以下输出:-

            total        used        free      shared  buff/cache   available
Mem:        1863224      966628       94584       88584      802012      620712
Swap:       1048572      167936      880636

为了找到空闲内存,

free = total -(used + buffcache)
free = 1863224 - (966628+802012)
     = 94584 which is correct 

如何计算可用内存?可用内存和空闲内存有什么区别?

答案1

free联机帮助页:

   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, avail‐
          able on kernels 3.14, emulated on kernels 2.6.27+, otherwise the
          same as free)

所以,这是从其他数字得出的估计值(不是精确计算的数字) - 它是大致可用内存加上可用缓冲区/缓存。

相关内容