JRuby Rails App中org.jruby.RubyRegexp $ RegexpCache的非常大的保留堆大小 [英] Very large retained heap size for org.jruby.RubyRegexp$RegexpCache in JRuby Rails App

查看:74
本文介绍了JRuby Rails App中org.jruby.RubyRegexp $ RegexpCache的非常大的保留堆大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经分析了应用程序的堆转储文件(在Tomcat上使用jruby 1.7.8运行).

We have analysed a heap dump file for our application (running on Tomcat with jruby 1.7.8).

它向我们显示了org.jruby.RubyRegexp $ RegexpCache类的保留堆大小非常大(439,459,128).这是我们的内存使用量的48%

It shows us that the retained heap size is very large (439,459,128) for the class org.jruby.RubyRegexp$RegexpCache. This is 48% of our memory usage

查看该文件,它是启动时创建的3个最终静态对象(patternCache/quotedPatternCache/preprocessedPatternCache)

Looking at the source code for that file it is 3 final static object created at startup (patternCache / quotedPatternCache / preprocessedPatternCache)

这似乎是JRuby的核心部分.我的问题是,拥有如此大比例的堆专用于此缓存是否正常?

This seems to be a pretty core part of JRuby. My question is, is it normal to have such a large percentage of the heap to be dedicated to this cache?

推荐答案

它可能通过Rails/gems/user-code源缓存了大多数Regexp对象...因此它可能非常庞大.除非您遇到泄漏(内存不足的问题),否则一切都很好,因为实际的缓存都包装在软引用中,这意味着直到有足够的内存(堆大小),它们才会从垃圾回收中保留,但是一旦您分配不适合所有(或某些)缓存的块可能会收集垃圾.

it probably cached most of the Regexp objects through out the Rails/gems/user-code source ... so it might be quite huge. unless you run into a leak (out-of-memory issue) it's all fine since the actual caches are wrapped in a soft reference, that means until there's enough memory (heap size) they will be held from garbage collection but as soon as you allocate a chunk that does not fit all (or some) of those caches may get garbage collected.

这篇关于JRuby Rails App中org.jruby.RubyRegexp $ RegexpCache的非常大的保留堆大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆