免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 19489 | 回复: 11
打印 上一主题 下一主题

linux可以限定buffers、cached的最大值吗? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-07-19 21:28 |只看该作者 |倒序浏览
5可用积分
linux可以限定buffers、cached的最大值吗?
linux的buffers、cached不断增大,又不释放,导致占用内存过多,能否设定buffers、cached占用的最大值?比如buffers 8G、cached 32G?

论坛徽章:
0
2 [报告]
发表于 2010-08-06 14:58 |只看该作者
回复 1# zxe

you don't need to, just treat buffer&cache as free memory.

however you can reduce inode&dentry cache a bit with  vfs_cache_pressure

    http://honglus.blogspot.com/2010 ... x-memory-cache.html

#Tune vfs_cache_pressure
If dentry cache or inode cache use too much memory, if it is not application abnormal behaviour to read/write large number of files. You can suppress dentry cache or inode cache memory usage by raising vm.vfs_cache_pressure to higher value e.g 500 or 1000


vfs_cache_pressure
Controls the tendency of the kernel to reclaim the memory which is used for
caching of directory and inode objects.
At the default value of vfs_cache_pressure=100 the kernel will attempt to
reclaim dentries and inodes at a "fair" rate with respect to pagecache and
swapcache reclaim. Decreasing vfs_cache_pressure causes the kernel to prefer to retain dentry and inode caches. When vfs_cache_pressure=0, the kernel will never reclaim dentries and inodes due to memory pressure and this can easily
lead to out-of-memory conditions. Increasing vfs_cache_pressure beyond 100
causes the kernel to prefer to reclaim dentries and inodes

论坛徽章:
0
3 [报告]
发表于 2010-08-06 15:39 |只看该作者
linux可以限定buffers、cached的最大值吗?
linux的buffers、cached不断增大,又不释放,导致占用内存过多 ...
zxe 发表于 2010-07-19 21:28


可以通过这种方式来手动释放

  1. root@platinum:~
  2. # free
  3.              total       used       free     shared    buffers     cached
  4. Mem:       4054056    3259948     794108          0     294540    2010028
  5. -/+ buffers/cache:     955380    3098676
  6. Swap:      6434028       5832    6428196
  7. root@platinum:~
  8. # echo 3 > /proc/sys/vm/drop_caches
  9. root@platinum:~
  10. # free
  11.              total       used       free     shared    buffers     cached
  12. Mem:       4054056    1051008    3003048          0      22304     273676
  13. -/+ buffers/cache:     755028    3299028
  14. Swap:      6434028       5832    6428196
  15. root@platinum:~
  16. #
复制代码

论坛徽章:
0
4 [报告]
发表于 2010-08-13 11:24 |只看该作者
  1. -bash-3.00$ ls
  2. block_dump              dirty_ratio                legacy_va_layout      min_free_kbytes     overcommit_ratio    swappiness
  3. dirty_background_ratio  dirty_writeback_centisecs  lowmem_reserve_ratio  nr_pdflush_threads  page-cluster        vfs_cache_pressure
  4. dirty_expire_centisecs  laptop_mode                max_map_count         overcommit_memory   swap_token_timeout
复制代码
我的vm下面只有上面这些条目, 我的内核是精简过的 2.6.15.4,drop_caches是要开启那个选项,还是此版本没有呢。

论坛徽章:
0
5 [报告]
发表于 2010-08-13 11:26 |只看该作者
  1. -bash-3.00$ ls
  2. block_dump              dirty_ratio                legacy_va_layout      min_free_kbytes     overcommit_ratio    swappiness
  3. dirty_background_ratio  dirty_writeback_centisecs  lowmem_reserve_ratio  nr_pdflush_threads  page-cluster        vfs_cache_pressure
  4. dirty_expire_centisecs  laptop_mode                max_map_count         overcommit_memory   swap_token_timeout
复制代码
我的vm下面只有上面这些条目, 我的内核是精简过的 2.6.15.5,drop_caches是要开启那个选项,还是此版本没有呢。

论坛徽章:
59
2015七夕节徽章
日期:2015-08-24 11:17:25ChinaUnix专家徽章
日期:2015-07-20 09:19:30每周论坛发贴之星
日期:2015-07-20 09:19:42ChinaUnix元老
日期:2015-07-20 11:04:38荣誉版主
日期:2015-07-20 11:05:19巳蛇
日期:2015-07-20 11:05:26CU十二周年纪念徽章
日期:2015-07-20 11:05:27IT运维版块每日发帖之星
日期:2015-07-20 11:05:34操作系统版块每日发帖之星
日期:2015-07-20 11:05:36程序设计版块每日发帖之星
日期:2015-07-20 11:05:40数据库技术版块每日发帖之星
日期:2015-07-20 11:05:432015年辞旧岁徽章
日期:2015-07-20 11:05:44
6 [报告]
发表于 2010-08-13 23:19 |只看该作者
内存区域,内核没有参数限制,但是数据库软件(如Oracle)有限制的参数。

论坛徽章:
0
7 [报告]
发表于 2010-08-20 09:50 |只看该作者
可以,编译内核中设定。

论坛徽章:
0
8 [报告]
发表于 2010-08-20 10:04 |只看该作者
看来确实可以手动清理,收藏一下!

论坛徽章:
5
NBA常规赛纪念章
日期:2015-05-04 22:32:03操作系统版块每日发帖之星
日期:2015-11-09 06:20:00操作系统版块每日发帖之星
日期:2015-11-10 06:20:00数据库技术版块每日发帖之星
日期:2016-01-14 06:20:00IT运维版块每日发帖之星
日期:2016-01-16 06:20:00
9 [报告]
发表于 2010-08-23 22:27 |只看该作者
学习中,我还不知道怎么回事呢。

论坛徽章:
0
10 [报告]
发表于 2010-08-25 17:31 |只看该作者
可以的,但是忘了如何操作了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP