虽然内存cache对文件系统有加速,但是cache太多的文件会感觉内存不太够用,甚至系统被逼使用swap,导致系统响应变的巨慢.
有啥办法可以让它变快呢?
或
就可以让它自动的释放不用的cache了.
相让它开机启动自动设置,就编辑/etc/sysctl.conf把vm.drop_caches = 3放进去吧.
下面是官方说明:
/proc/sys/vm/drop_caches (since Linux 2.6.16)
Writing to this file causes the kernel to drop clean caches,
dentries and inodes from memory, causing that memory to become free.
To free pagecache, use echo 1 > /proc/sys/vm/drop_caches;
to free dentries and inodes, use echo 2 > /proc/sys/vm/drop_caches;
to free pagecache, dentries and inodes, use echo 3 >/proc/sys/vm/drop_caches.
用后感:
试了一下,以前只有100多M的自由空间,甚至swap还被用了200多M,现在剩余空间多大,你自己看看...空闲内存接近1.8G
系统变得非常流畅.娃哈哈
[root@rains ~]# free
total used free shared buffers cached
Mem: 3913564 2119816 1793748 0 7168 318448
-/+ buffers/cache: 1794200 2119364
Swap: 4000148 0 4000148
[root@rains ~]#