linux 手动清除缓存

2015-12-03

 

free -m
cat /proc/sys/vm/drop_caches
#sync将所有未写的系统缓存区write to disk,包含已修改的i node、已延迟的块I\O和读写映射
sync
#drop_caches默认是0,提供了三个选项操作
1 清空页缓存   2 清空inode和目录树缓存  3 清空所有的缓存
echo 3 > /proc/sys/vm/drop_caches
cat /proc/sys/vm/drop_caches
free -m

 

[root@sdb2 ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          2883       2812         71          0        157       2514
-/+ buffers/cache:        140       2743
Swap:         4095          2       4093
[root@sdb2 ~]# cat /proc/sys/vm/drop_caches
0
[root@sdb2 ~]# sync
[root@sdb2 ~]# echo 3 > /proc/sys/vm/drop_caches
[root@sdb2 ~]# cat /proc/sys/vm/drop_caches
3
[root@sdb2 ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          2883         92       2791          0          0         10
-/+ buffers/cache:         81       2802
Swap:         4095          2       4093

 

posted @ 2015-12-03 14:09  岑亮  阅读(451)  评论(0编辑  收藏  举报