歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> linux下釋放內存的cache

linux下釋放內存的cache

日期:2017/3/1 14:51:50   编辑:關於Linux
linux下釋放內存的cache 雖然內存cache對文件系統有加速,但是cache太多的文件會感覺內存不太夠用,甚至系統被逼使用swap,導致系統響應變的巨慢. 有啥辦法可以讓它變快呢? sysctl -w vm.drop_caches = 3 或 echo 3 > /proc/sys/vm/drop_caches 就可以讓它自動的釋放不用的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 ~]#
Copyright © Linux教程網 All Rights Reserved