[root@host ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@host ~]#
[root@host ~]# free -m
total used free shared buff/cache available
Mem: 7821 183 7486 8 152 7417
Swap: 1023 0 1023
[root@host ~]#
参数说明:
关于 buffers 我们举个例子:现在有一块 ext4 的 U 盘,此时往里面 cp 一个 3 MB 的 MP3 格式的文件,但 U 盘的灯没有跳动(其实文件写入到了 buffers ),过了一会儿(或者手工执行 sync 命令)U 盘的灯就跳动起来了(文件正式写入到 U 盘);卸载设备时会清空缓存,所以有些时候卸载一个设备需要等上几秒钟(将所有的缓存数据全部写入到 U 盘)。
[root@host ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@host ~]#
[root@host ~]# free -m
total used free shared buff/cache available
Mem: 位置一 位置二 位置三 位置四 位置五 位置六
Swap: 位置七 位置八 位置九
[root@host ~]#
新的输出结果有三个地方发生了改变:
根据第一个样式中的公式可得:
[root@host ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@host ~]#
[root@host ~]# free -m
total used free shared buff/cache available
Mem: 7821 183 7486 8 152 7417
Swap: 1023 0 1023
[root@host ~]#
已分配的物理内存 = 系统和应用程序使用的内存(这里面已经包含了共享内存)+ buffers 缓存 + cached 缓存,即 183 MB + 152 MB = 335 MB 。
未分配的物理内存 = 物理内存总量 – 已分配的物理内存,即 7821 MB – 335 MB = 7486 MB 。