free的使用方法:
[root@Dasoncheng ~]# free
total used free shared buff/cache available
Mem: 1883740 51052 1458892 296 373796 1677328
Swap: 0 0 0
[root@Dasoncheng ~]# free -h
total used free shared buff/cache available
Mem: 1.8G 49M 1.4G 296K 365M 1.6G
Swap: 0B 0B 0B
[root@Dasoncheng ~]# free -m/g/h
其中:
- total:代表内存总大小;
- used:表示使用的实际内存大小;
- free:剩余物理内存大小(未分配、纯剩余);
- share:共享内存大小、无需关注;
- buff/cache:缓冲(缓冲如:cpu到io硬盘,硬盘写入速度慢 需要先将一部分数据缓存到内存)和缓存(如:io硬盘到cpu,从硬盘读取 需要先把数据临时放内存里面 大小;
- available:实际可使用的内存大小;(free+buff/cache只分配,但未使用的内存)
total=used + free + buff/cache
available=free + buff/cache(分配但未使用的内存)
其中:used已使用内存,和buff/cache被占用的内存没有关系;