Redhat Linux7下如何用drop_caches手动清理缓存

清理缓存(drop_caches)的官方文档如下:
http://www.kernel.org/doc/Documentation/sysctl/vm.txt
==============================================================
drop_caches

Writing to this will cause the kernel to drop clean caches, as well as
reclaimable slab objects like dentries and inodes.  Once dropped, their
memory becomes free.


To free pagecache:
echo 1 > /proc/sys/vm/drop_caches
To free reclaimable slab objects (includes dentries and inodes):
echo 2 > /proc/sys/vm/drop_caches
To free slab objects and pagecache:
echo 3 > /proc/sys/vm/drop_caches

==============================================================

# cat /proc/sys/vm/drop_caches
0 //默认是0;1-清空页缓存;2-清空inode和目录树缓存;3-清空所有缓存

示例如下:
[root@chenfeng ~]# sync    //在清空缓存之前使用sync命令同步数据到磁盘

[root@chenfeng ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:           1824        1165          93          10         566         421
Swap:             0           0           0

[root@chenfeng ~]# echo 3 > /proc/sys/vm/drop_caches  // 清空所有缓存

[root@chenfeng ~]# free -m  //可以看到缓存buff/cache的值明显减少了
              total        used        free      shared  buff/cache   available
Mem:           1824        1123         492          10         209         514
Swap:             0           0           0

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/15498/viewspace-2121300/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/15498/viewspace-2121300/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值