General Purpose Script Handler

Aug 31, 2010 at 2:37 AM

I am working on using Jint as a general purpose script handler where I need to handle the state of possibly 10,000 or more scripts.  If I use an instance of JintEngine, each instance of that class (and it's subclasses) total out to about 140KB per instance.  It appears as though almost all of this is in the JsGlobal class.  It looks like there is a lot of stuff in there that could potentially be created as static possibly.  In my testing I modified ExecutionVisitor to use a single static instance of JsGlobal and almost everything works (Eval() does not work but for me that's no big deal).  Any thoughts on large issues I might run into doing it this way or is there another easy way to reduce the memory footprint?

I have also considered keeping a pool of 1000 or so ExecutionVisitors and shuffling in and out 'Program' instances as needed, this wouldn't be ideal but could potentially work.

Overall Jint has been great, thanks!

Aug 31, 2010 at 5:34 PM

I suppose this can be an issue as all the global variables would be shared, and this could be an issue. Although if a script modifies the global prototypes, this could also lead to unexpected behavior. Though if you use local scoping, and no script can update the global objects, then it 'might' be fine. I would prefer the technique implying a pool of execution visitors.