Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

JEP Singleton?

Calvin
2008-04-18
2013-04-26
  • Calvin
    Calvin
    2008-04-18

    Just curious about the best practices of using JEP.  I noticed creating a new instance of JEP also comes with hundreds of objects that the parser depends on.  There are noticeable memory problems when the application creates many instances of JEP.

    Should JEP be used as a singleton object?

    Thanks,

     
    • Nathan Funk
      Nathan Funk
      2008-04-18

      It depends on your application. If you have multiple threads you would need to be careful. If you have a single thread, then yes, using JEP as a singleton is definitely recommended if you are running into memory issues.

      Please from now on post on the new Jep forums at

         http://groups.google.com/group/jep-users

      Best regards,

      Nathan Funk

       
    • There are ways in which you can minimise the space usage. There issues have been given a lot of attention in the Jep 3.2 release see
          http://www.singularsys.com/jep/doc/html/serialization.html
      which explains details of efficiently working with threads. Basically you can create new light-weight jep classes which  share some components, like the parser, but creates those parts which are necessary for thread-safe operation, (the evaluator, variable table and expressions).

      In 2.4 release there are some facilities offered by the djep extensions, in particular the org.lsmp.djep.xjep.xJep class see org.lsmp.djepExamples.ThreadTest for examples.

      Rich