linux-command/command/free.md

63 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

free
===
显示内存的使用情况
## 补充说明
**free命令** 可以显示当前系统未使用的和已使用的内存数目,还可以显示被内核使用的内存缓冲区。
### 语法
```
free(选项)
```
### 选项
```
-b以Byte为单位显示内存使用情况
-k以KB为单位显示内存使用情况
-m以MB为单位显示内存使用情况
-o不显示缓冲区调节列
-s<间隔秒数>:持续观察内存使用状况;
-t显示内存总和列
-V显示版本信息。
```
### 实例
```
free -m
total used free shared buffers cached
Mem: 2016 1973 42 0 163 1497
-/+ buffers/cache: 312 1703
Swap: 4094 0 4094
```
**第一部分Mem行解释**
```
total内存总数
used已经使用的内存数
free空闲的内存数
shared当前已经废弃不用
buffers Buffer缓存内存数
cached Page缓存内存数。
```
关系total = used + free
**第二部分(-/+ buffers/cache)解释:**
```
(-buffers/cache) used内存数第一部分Mem行中的 used buffers cached
(+buffers/cache) free内存数: 第一部分Mem行中的 free + buffers + cached
```
可见-buffers/cache反映的是被程序实实在在吃掉的内存而+buffers/cache反映的是可以挪用的内存总数。
第三部分是指交换分区。
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->