swap清理:
swapoff -a && swapon -a
注意:这样清理有个前提条件,空闲的内存必须比已经使用的swap空间大
cache清理:
sync; sync; sync;&& echo3 >/proc/sys/vm/drop_caches
sleep 2
echo 0>/proc/sys/vm/drop_caches
To free pagecache:
echo 1>/proc/sys/vm/drop_caches
To free dentries and inodes:
echo 2>/proc/sys/vm/drop_caches
To free pagecache,dentries and inodes:
echo 3>/proc/sys/vm/drop_caches
/proc/sys/vm/drop_caches 的值默认为0(所以我们清空后,还再恢复它的值为0)