简体   繁体   English

JRuby Rails App中的org.jruby.RubyRegexp $ RegexpCache的保留堆大小非常大

[英]Very large retained heap size for org.jruby.RubyRegexp$RegexpCache in JRuby Rails App

We have analysed a heap dump file for our application (running on Tomcat with jruby 1.7.8). 我们已经分析了应用程序的堆转储文件(在Tomcat上使用jruby 1.7.8运行)。

It shows us that the retained heap size is very large (439,459,128) for the class org.jruby.RubyRegexp$RegexpCache. 它向我们显示了org.jruby.RubyRegexp $ RegexpCache类的保留堆大小非常大(439,459,128)。 This is 48% of our memory usage 这是我们内存使用的48%

Looking at the source code for that file it is 3 final static object created at startup (patternCache / quotedPatternCache / preprocessedPatternCache) 查看该文件的源代码,它是启动时创建的3个最终静态对象(patternCache / quotedPatternCache / preprocessedPatternCache)

This seems to be a pretty core part of JRuby. 这似乎是JRuby的核心部分。 My question is, is it normal to have such a large percentage of the heap to be dedicated to this cache? 我的问题是,拥有如此大比例的堆专用于此缓存是否正常?

it probably cached most of the Regexp objects through out the Rails/gems/user-code source ... so it might be quite huge. 它可能通过Rails / gems / user-code源缓存了大多数Regexp对象...因此它可能非常庞大。 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. 除非您遇到泄漏(内存不足的问题),否则一切都很好,因为实际的缓存都包装在软引用中,这意味着直到有足够的内存(堆大小),它们才会从垃圾回收中保留,但是一旦您分配不适合所有(或某些)缓存的块可能会收集垃圾。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM