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?
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
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
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.