Menu

Possible Memory issue

Help
numbersman
2004-10-05
2013-03-07
  • numbersman

    numbersman - 2004-10-05

    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.

     
    • numbersman

      numbersman - 2004-10-06

      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.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.