C/C++教程

centos中释放缓存的方法

本文主要是介绍centos中释放缓存的方法,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
释放缓存区内存的方法
a)清理pagecache(页面缓存)
# echo 1 > /proc/sys/vm/drop_caches     或者 # sysctl -w vm.drop_caches=1

b)清理dentries(目录缓存)和inodes
# echo 2 > /proc/sys/vm/drop_caches     或者 # sysctl -w vm.drop_caches=2

c)清理pagecache、dentries和inodes
# echo 3 > /proc/sys/vm/drop_caches     或者 # sysctl -w vm.drop_caches=3


[root@test4_haili_dev hadoop-2.7.3]# free -m
             total       used       free     shared    buffers     cached
Mem:          7809       7159        650          0        324       2444
-/+ buffers/cache:       4390       3419 
Swap:          511         89        422 
[root@test4_haili_dev hadoop-2.7.3]# cat /proc/sys/vm/drop_caches
1
[root@test4_haili_dev hadoop-2.7.3]# echo 1 > /proc/sys/vm/drop_caches  
[root@test4_haili_dev hadoop-2.7.3]# free -m
             total       used       free     shared    buffers     cached
Mem:          7809       4345       3464          0          0         36
-/+ buffers/cache:       4308       3500 
Swap:          511         89        422 
[root@test4_haili_dev hadoop-2.7.3]# cat /proc/sys/vm/drop_caches 
1
[root@test4_haili_dev hadoop-2.7.3]# echo 2 > /proc/sys/vm/drop_caches
[root@test4_haili_dev hadoop-2.7.3]# cat /proc/sys/vm/drop_caches 
2
[root@test4_haili_dev hadoop-2.7.3]# free -m
             total       used       free     shared    buffers     cached
Mem:          7809       4303       3506          0          2         36
-/+ buffers/cache:       4265       3544 
Swap:          511         89        422 
[root@test4_haili_dev hadoop-2.7.3]# cat /proc/sys/vm/drop_caches
2
[root@test4_haili_dev hadoop-2.7.3]# echo 3 > /proc/sys/vm/drop_caches
[root@test4_haili_dev hadoop-2.7.3]# free -m
             total       used       free     shared    buffers     cached
Mem:          7809       4301       3508          0          0         36
-/+ buffers/cache:       4264       3544 
Swap:          511         89        422 
这篇关于centos中释放缓存的方法的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!