Has anyone used DynamicJava in a long running process. On a solaris box I am loading and running about 20 different scripts. Overtime I seem to be getting a lot of Token objects hanging out in memory and not being garbage collected.
My code is creating a new JavaCCParser and TreeInterpreter for each run of the scripts.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
After a week a tweaking and hair pulling I believe I found the answer to my own issue which i posted
This problem only occurrs if you declared a class in your script.
Looks like the issue is in the TreeInterpreter. If you define a class in your script code. The class methods get registered in a static map called methods in Treeinterpreter.
The registered values in the map contain references to the interpreter itself causing garbage collection on the that instance of the interpreter not to occur. The cleanup code in the finalize method is correct but because the reference to the interpreter is in the methods map values it does not get invoked.
A simple fix/test was to add a method done() that is a copy of the finalize() method in the TreeInterpreter. When I am done with the interperter instance I called done(). Then garbage collection seems to occur normally.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Has anyone used DynamicJava in a long running process. On a solaris box I am loading and running about 20 different scripts. Overtime I seem to be getting a lot of Token objects hanging out in memory and not being garbage collected.
My code is creating a new JavaCCParser and TreeInterpreter for each run of the scripts.
After a week a tweaking and hair pulling I believe I found the answer to my own issue which i posted
This problem only occurrs if you declared a class in your script.
Looks like the issue is in the TreeInterpreter. If you define a class in your script code. The class methods get registered in a static map called methods in Treeinterpreter.
The registered values in the map contain references to the interpreter itself causing garbage collection on the that instance of the interpreter not to occur. The cleanup code in the finalize method is correct but because the reference to the interpreter is in the methods map values it does not get invoked.
A simple fix/test was to add a method done() that is a copy of the finalize() method in the TreeInterpreter. When I am done with the interperter instance I called done(). Then garbage collection seems to occur normally.