Skip to content

Commit

Permalink
Merge pull request #715 from matthias-fratz-bsz/develop
Browse files Browse the repository at this point in the history
disable JRuby's Variable Sharing feature
  • Loading branch information
jcoyne authored Dec 18, 2024
2 parents 4378808 + bd6d05a commit 3242e89
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.slf4j.LoggerFactory;

import javax.script.Invocable;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
Expand Down Expand Up @@ -71,6 +72,14 @@ final class JRubyDelegateProxy implements DelegateProxy {
System.setProperty("org.jruby.embed.localvariable.behavior", "transient");

scriptEngine = new ScriptEngineManager().getEngineByName("jruby");

// Workaround for a memory leak in JRuby's BiVariableMap: By default, all
// instance variables are stored into BiVariableMap so they are accessible
// from Java. However, there is currently no mechanism for ever removing
// them, forming a memory leak.
// That feature isn't used by Cantaloupe, so we can just disable it.
scriptEngine.getContext().setAttribute("org.jruby.embed.sharing.variables",
false, ScriptContext.ENGINE_SCOPE);
}

/**
Expand Down

0 comments on commit 3242e89

Please sign in to comment.