CentOS 6及以前

$ free
total used free shared buffers cached
Mem: 4040360 4012200 28160 0 176628 3571348
-/+ buffers/cache: 264224 3776136
Swap: 4200956 12184 4188772
$
内存的使用分作4部分:
  • A. 程序使用的;
  • B. 未被分配的;
  • C. Buffers (buffer cache)
  • D. Cached (page cache)
显然,A (程序使用的) 肯定是used,B (未被分配的) 肯定是free。但是,C (Buffers) 和 D (Cached) 是算作used还是算作free呢?一方面,它们已经被分配了,可以算作used;另一方面,当程序需要时,可以回收它们来使用,可以算作free。所以,怎么算都合理。这就是在free命令的output中,第一行和第二行的区别
  • 第一行(Mem):Buffers和Cached被算作used。也就是说,它的free是指 B (未被分配的);它的used是指 A + C + D;
  • 第二行(-/+ buffers/cache):Buffers和Cached被算作free。也就是说,它的used是指 A (程序使用的);它的free是指 B + C + D;行名称“-/+ buffers/cache”的含义就是“把Buffers和Cached从used减下来,加到free里”。
搞清这些之后,我们可以算出A,B,C和D各自的值:
  • A=264224
  • B=28160
  • C=176628
  • D=3571348
可见验证一下:
  • total=A + B + C + D
  • 第一行used = A + C + D
  • 第二行free  = B + C + D

CentOS 7

free命令的out:
              total        used        free      shared  buff/cache   available
Mem: 1012952 252740 158732 11108 601480 543584
Swap: 1048572 5380 1043192
 
首先,C (Buffers) 和D (Cached)被和到一起,即buff/cache;
其次,used就是指A (程序使用的);free就是指B (未被分配的);
另外,CentOS 7中加入了一个available,它是什么呢?手册上是这么说的:
 
  • MemAvailable: An estimate of how much memory is available for starting new applications, without swapping.

前面说过,当程序需要时,可以回收C (Buffers)和D (Cached),那么MemAvailabe不就是B+C+D吗?当程序需要时可以回收C和D,这句话以前是正确,但是现在就不精确了:因为, 现在,C和D中不是所有的内存都可以被回收。所以,大致可以这么理解,MemAvailable = B (未被分配的) + C (Buffers) + D (Cached) - 不可回收的部分。哪些不可回收呢?共享内存段,tmpfs,ramfs等。详细的介绍如下:

 
/proc/meminfo: provide estimated available memory
Many load balancing and workload placing programs check /proc/meminfo to estimate how much free memory
is available. They generally do this by adding up "free" and "cached", which was fine ten years
ago,
but is pretty much guaranteed to be wrong today.
It is wrong because Cached includes memory that is not freeable as page cache, for example shared
memory
segments, tmpfs, and ramfs, and it do esnot include reclaimable slab memory, which can take up
a large
fraction of system memory on mostly idle systems with lots of files.
Currently, the amount of memory that is available for a new workload,without pushing the system
into swap,
can be estimated from MemFree, Active(file), Inactive(file), and SReclaimable, as well as the
"low"watermarks
from /proc/zoneinfo.
However, this may change in the future, and user space really should not be expected to know kernel
internals
to come up with an estimate for the amount of free memory.
It is more convenient to provide such an estimate in /proc/meminfo. If things change in the future,
we only
have to change it in one place.

centos free详解的更多相关文章

  1. centos LVM详解

    title: centos LVM详解 date: 2018-04-24 14:00:03 tags: [linux,centos,LVM] --- 知识了解 LVM关系图 fdisk命令详解 [ro ...

  2. (转)CentOS分区操作详解

    CentOS分区操作详解 原文:http://blog.csdn.net/yonggeit/article/details/77924393 磁盘分区 分区格式的两种选择:MBR和GPT 分区命令: ...

  3. Vmware12安装centos系统详解

    vmware12安装centos7系统详解 用虚拟机12安装centos7系统详细安装过程,后附centos7下载地址. 工具/原料 虚拟机12 centos7系统镜像 方法/步骤 1 1.百度搜索c ...

  4. Linux学习之CentOS(八)----详解文件的搜寻、查找(转)

    which (寻找『运行档』) [root@www ~]# which [-a] command 选项或参数: -a :将所有由 PATH 目录中可以找到的命令均列出,而不止第一个被找到的命令名称 分 ...

  5. CentOS 6.5自动化运维之基于DHCP和TFTP服务的PXE自动化安装centos操作系统详解

    前言    如果要给很多台客户端主机安装操作系统,要是每一台都拿张安装光盘一台一台主机的去装系统那就太浪费时间和精力了.在生产环境中也不实际,要实现为多台主机自动安装操作系统,那我们怎么实现自动化安装 ...

  6. centos crontab详解

    1.crontab安装 [root@CentOS ~]# yum install vixie-cron [root@CentOS ~]# yum install crontabs 说明:vixie-c ...

  7. CentOS 6.3下Samba服务器的安装与配置方法(图文详解)

    这篇文章主要介绍了CentOS 6.3下Samba服务器的安装与配置方法(图文详解),需要的朋友可以参考下   一.简介  Samba是一个能让Linux系统应用Microsoft网络通讯协议的软件, ...

  8. 【转】centos关机与重启命令详解

    连接:http://blog.csdn.net/jiangzhengdong/article/details/8036594 Linux centos关机与重启命令详解与实战 Linux centos ...

  9. centos中crontab(计时器)用法详解

    关于crontab: crontab命令常见于Unix和类Unix的操作系统之中,用于设置周期性被执行的指令.该命令从标准输入设备读取指令,并将其存放于“crontab”文件中,以供之后读取和执行.该 ...

随机推荐

  1. Docker入门与实战讲解

    转载自:http://blog.csdn.net/relax_hb/article/details/69668815 简述 Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包 ...

  2. TF(1): 基础理论

    TensorFlow最初由Google大脑的研究员和工程师开发出来,用于机器学习和神经网络方面的研究,于2015.10宣布开源,在众多深度学习框架中脱颖而出,在Github上获得了最多的Star量.T ...

  3. Linux系统目录权限chmod误操作权限修复方法

    Linux中,如果意外误操作将/目录权限批量设置,比如chmod -R 777 / ,系统中的大部分服务以及命令将无法使用,这时候可以通过系统自带的getfacl命令来拷贝和还原系统权限,若是其他系统 ...

  4. 高性能mysql 第六章查询性能优化 总结(上)查询的执行过程

    6  查询性能优化 6.1为什么查询会变慢 这里说明了的查询执行周期,从客户端到服务器端,服务器端解析,优化器生成执行计划,执行(可以细分,大体过程可以通过show profile查看),从服务器端返 ...

  5. IDEA2016 maven项目配置Junit

    添加插件:File->Settings->Plugins 设置生成模式:File->Settings->Other Settings 修改模板:File->Setting ...

  6. python网页爬虫开发之四-串行爬虫代码示例

    实现功能:代理.限速.深度.反爬 import re import queue import urllib.parse import urllib.robotparser import time fr ...

  7. Vue--生命周期函数

    生命周期函数就是组件挂载.以及组件销毁的时候触发的一系列方法,这些方法叫做生命周期函数: beforeCreate(){ console.log('实例创建之前-1') }, created(){ c ...

  8. Python 爬虫 Vimeo视频下载链接

    python vimeo_d.py https://vimeo.com/228013581 在https://vimeo.com/上看到稀罕的视频 按照上面加上视频的观看地址运行即可获得视频下载链接 ...

  9. win7 英文版 中文乱码

    win7 为了使用英文的 pcb 软件,把语言包改为英文版后,碰到一部分中文会变成乱码.通过下面方法可以识别: control panel --> region and language --& ...

  10. [Python]查询oracle导出结果至Excel并发送邮件

    环境:Linux +python2.7+oracle11g 1.提前安装xlwt(excel写入操作模块),cx_Oracle(oracle操作模块) cx_Oracle的安装步骤详见链接:https ...