linux cached

来源:互联网 发布:企业邮箱域名入口 编辑:程序博客网 时间:2024/05/29 17:53

我们用free命令查看系统内存使用情况的时候会发现:

#free -m

             total       used       free     shared    buffers     cachedMem:         24359      11240      13119          0          0      10706-/+ buffers/cache:        533      23826Swap:         4095          0       4095

 

1、total = used + free

2、cached比较大,甚至我遇见过内存剩余只有7M的情况,这个时候cached非常大,基本上接近等于total了,这个时候打开文件或者传输文件的时候可用内存很小,程序可能就会用到交换分区swap了,所以会发现机器速度变慢的情况。

其实这缓存内存(Cache Memory)在你需要使用内存的时候会自动释放,所以你不必担心没有内存可用。如果你希望手动去释放Cache Memory(缓存内存)的话也是有办法的。

释放方法有三种(系统默认值是0,释放之后你可以再改回0值):

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

注意:在清空缓存前我们需要在linux系统中执行一下sync命令,将缓存中的未被写入磁盘的内容写到磁盘上。



0 0
原创粉丝点击