os: ubuntu 16.04
查看默认值
# cat /proc/sys/vm/drop_caches
0
用法
root@xxoo:~# free -m
total used free shared buff/cache available
Mem: 984 63 96 303 825 424
Swap: 979 4 975
root@xxoo:~#
root@xxoo:~# echo 3 > /proc/sys/vm/drop_caches
root@xxoo:~#
root@xxoo:~# free -m
total used free shared buff/cache available
Mem: 984 63 518 303 402 476
Swap: 979 4 975
在 free、buff/cache、available 这三列 均有明显的变化。
drop_caches 有几个不同的值,代表不同的含义:
free pagecache, use 1
root@xxoo:~# echo 1 > /proc/sys/vm/drop_caches;
free dentries and inodes, use 2
root@xxoo:~# echo 2 > /proc/sys/vm/drop_caches;
free pagecache, dentries and inodes, use 3
root@xxoo:~# echo 3 >/proc/sys/vm/drop_caches.
所以通常使用 3,一步到位,省时省心。