2020-12-23 13:35:54 +08:00
|
|
|
|
# Linux 释放缓存空间
|
|
|
|
|
|
|
|
|
|
Linux 下释放 cache 空间命令如下:
|
|
|
|
|
|
|
|
|
|
```bash
|
2024-05-30 16:22:41 +08:00
|
|
|
|
# 在释放缓存前应该先
|
|
|
|
|
sync
|
|
|
|
|
# 手动释放内存
|
2020-12-23 13:35:54 +08:00
|
|
|
|
echo 3 > /proc/sys/vm/drop_caches
|
2024-05-30 16:22:41 +08:00
|
|
|
|
# 查看内存是否已经释放
|
|
|
|
|
free -h
|
2020-12-23 13:35:54 +08:00
|
|
|
|
```
|
2024-05-30 16:22:41 +08:00
|
|
|
|
|
|
|
|
|
drop_caches 的值可以是 0-3 之间的数字,代表不同的含义:
|
|
|
|
|
|
|
|
|
|
- 0:不释放(系统默认值)
|
|
|
|
|
- 1:释放页缓存
|
|
|
|
|
- 2:释放dentries和inodes
|
|
|
|
|
- 3:释放所有缓存
|