LoginSignup
8
9

More than 5 years have passed since last update.

ページキャッシュをクリアする

Posted at

2.6.16 以降で対応されている。

/proc/sys/vm/drop_caches に書き込みをする。先に sync を実行したほうがいいようだ。

# sync
# echo 1 > /proc/sys/vm/drop_caches

ページキャッシュをクリアするには上記の通り /proc/sys/vm/drop_caches に 1 を書き込めば良い。2 や 3 にするとページキャッシュ以外もクリアできる。

  1. ページキャッシュ
  2. dentry, inode
  3. ページキャッシュ, dentry, inode

試してみると次のとおり:

# free
             total       used       free     shared    buffers     cached
Mem:       8160936    2600428    5560508          0       1048      72616
-/+ buffers/cache:    2526764    5634172
Swap:      8385920      14624    8371296
# echo 1 > /proc/sys/vm/drop_caches
# free
             total       used       free     shared    buffers     cached
Mem:       8160936    2563180    5597756          0        412      35784
-/+ buffers/cache:    2526984    5633952
Swap:      8385920      14624    8371296

buffers と cached が減っていることがわかる。

参考: http://www.kernel.org/doc/man-pages/online/pages/man5/proc.5.html


RHEL 4.6 なら,カーネルは 2.6.9 だがこの機能がバックポートされているようだ.

  • Added /proc/sys/vm/drop_caches to clear pagecache and slabcache on demand

RHEL は未確認だけど,CentOS 4.6 では使えた.

8
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
9