Ash McConnell
Ash McConnell

Reputation: 1337

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).

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

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

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?

Upvotes: 0

Views: 176

Answers (1)

kares
kares

Reputation: 7181

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.

Upvotes: 1

Related Questions