0

We have a problem with our Jython environment, meaning that after a certain amount of calls to eval on the PythonInterpreter object, we run into an 'Out of permgen memory' error.

Does anybody have any experience with this and how to solve it?

We are currently running on Jython 2.5.2.

Below is an excerpt of the code used to repeatedly invoke the interpreter.

public Map<String, String> invoke(Map<String, String> parameters) {

    //logger.info("Executing script for parameters: " + parameters);

    this.interpreter.set("inputDict", parameters);
    PyDictionary dict =  (PyDictionary)this.interpreter.eval(ScriptComposer.mainMethodName + "(inputDict)");

    //logger.info("Done executing script for parameters: " + parameters);

    return dict;

}
Tudor Vintilescu
  • 1,450
  • 2
  • 16
  • 28

1 Answers1

1

Well, I think I've figured out the problem, so just to help others who run into this, I'll post a few hints.

For Jython versions prior to 2.5.2 there was indeed a bug concerning class generation and class reference hold which meant that after a certain ammount of calls to eval/exec one would have run into the problem described above.

However, when using Jython version 2.5.2 and later there isn't any problem per se, but when simultainously using several PythonInterpreter objects on different threads the necessary memory for permanent generation objects (classes and static members) raises, so you have to start your VM with:

-XX:PermSize=$START_JVM_PERMSIZE -XX:MaxPermSize=$MAX_JVM_PERMSIZE 

thus increasing the start and maximum memory allocated for permanent generation objects.

Hope this will help others to solve this issue faster.

Tudor Vintilescu
  • 1,450
  • 2
  • 16
  • 28