-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Very large retained heap size for org.jruby.RubyRegexp$RegexpCache in JRuby Rails App #2078
Comments
We've tested this out and let it run until destruction. The regexp cache fills up the heap and the transaction time increases and increases (90 secs instead of 1-2 secs). Is there any way to limit the size of this cache? |
same thing happened in my environment. repro code# example.rb
count = 0
while(true)
count += 1
Regexp.new("test#{count}")
end
|
We have found the source of the problem, it was slightly more hidden than your reproduction. We were doing a substitution (when trying to filter params) that happened on every transaction.
The value.sub! in there was the problem, the value was changing with every request and being added to the Regex Cache. We fixed the problem by using value.replace("[FILTERED]") instead - no more leak. I do think that the cache entries should perhaps have a TTL or a maximum size to avoid something like this. |
I can't reproduce this on 1.7.16.1 or master - the SoftReferences get collected reliably. Using:
Master: 1.7.16.1:
|
@cheald It seems GC collect except system to access to
I think, reason to not reproduce at cheald's code is interval time to make In actuary, "access to thank you. |
Thank you for reporting this. Yes, this implementation is insufficient. We are exploring another. |
…ache keys are shorter-lived than the SoftReferences used before, but it will allow for the rapid expiration of memory-hungry one-shot regexes as well. Fixes jruby#2078
Thanks guys - really glad that our 2 weeks of pain has at least resulted in JRuby being improved. Thanks for your hard work! |
Should be fixed now in jruby-1_7 and master. The new cache appears to run @cheald's benchmark 3x faster than MRI, 2x faster than Rubinius, and retained heap holds steady. Not sure how best to write a test for this. Will try to add one into the JUnit suite. |
I've asked a question in stackoverflow, but I'll paste here for convenience
"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?
"
http://stackoverflow.com/questions/26630565/very-large-retained-heap-size-for-org-jruby-rubyregexpregexpcache-in-jruby-rail
Thanks for your help
All the best,
Ash
The text was updated successfully, but these errors were encountered: