disable JRuby's Variable Sharing feature #715
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This avoids a memory leak in JRuby 9.4.3.0 (probably at least 9.4.x).
If Variable Sharing is enabled, JRuby stores all Ruby instance variables into a
BiVariableMap
object for access from Java. As of the current 9.4.10.0 development version, thisBiVariable
object is never removed from itsBiVariableMap
, and thus never gets garbage-collected.JRubyDelegateProxy
creates a new instance of the RubyCustomDelegate
object, so any use of instance variables in that object leaks a bit of memory after each request. This eventually grinds Cantaloupe to a halt.Disabling Variable Sharing is a workaround until this can be fixed in JRuby. JRuby's Variable Sharing feature isn't needed by the code in
JRubyDelegateProxy
.This memory leak is similar to the one described in #712, but the mechanism is slightly different. I'm proposing the workaround because according to synthetic tests, it should also reduce the impact of that other leak quite significantly.