|
发现内存消耗殆尽,使用top查看,应用进程占用的内存并不多,使用free命令查看,发现大部分的内存都被cached占用了。 只能使用手动的方式清理缓存了: echo 3 > /proc/sys/vm/drop_caches 清空所有的缓存 在使用free命令查看,内存释放了。 下面说一下:drop_caches: 清空 pagecache:, N1 }4 h, K( b' }/ Y
echo 1 > /proc/sys/vm/drop_caches! ~8 r; W3 g1 \1 b* F
或者:
6 F7 j, s4 P) V" J sysctl -w vm.drop_caches=1 清空 dentries 和 inodes:
2 y! x8 X1 O/ o5 X# K. k7 M echo 2 > /proc/sys/vm/drop_caches
D( V! }; J+ {8 U& r; p 或者:- n) L; a4 P# t0 t/ r$ @6 c" b% u9 ~
sysctl -w vm.drop_caches=2 清空所有缓存(pagecache、dentries 和 inodes):3 I/ ^3 ~& [- n
echo 3 > /proc/sys/vm/drop_caches
, K+ d. C1 c. L 或者:
5 S( c* p9 s7 f. l sysctl -w vm.drop_caches=3
* L+ z3 c, }9 @/ l; P虽然手动清理缓存,治标不治本,但是暂时解决了缓存耗尽的问题,然后google了一下,通过修改sysctl.conf文件的下面几个参数,可以优化一下系统自动回收缓存: vm.vfs_cache_pressure #系统在进行内存回收时,安装顺序回收page_cache, inode cache, dentry cache和swap_cache,默认值是100 值越大inode cache和dentry cache的回收速度会越快 vm.min_free_kbytes #计算开始内存回收的阀值,值越大表示回收也早。 3 x+ E' G( O4 V2 ^$ g1 m
|