> CentOS > CentOS入门 >

CentOS下清理swap和buffer/cache

swap清理:


  1. swapoff -a && swapon -a

注意:这样清理有个前提条件,空闲的内存必须比已经使用的swap空间大

 

cache清理:


  1. sync; sync; sync;&& echo3 >/proc/sys/vm/drop_caches

  2. sleep 2

  3. echo 0>/proc/sys/vm/drop_caches

 

To free pagecache:


  1. echo 1>/proc/sys/vm/drop_caches

 

To free dentries and inodes:


  1. echo 2>/proc/sys/vm/drop_caches

 

To free pagecache,dentries and inodes:


  1. echo 3>/proc/sys/vm/drop_caches

/proc/sys/vm/drop_caches 的值默认为0(所以我们清空后,还再恢复它的值为0)

 

(责任编辑:IT)