Script objects are stateless, they only represent a compiled form of the JS program. They can safely be shared between threads, and executed concurrently. Indeed, you'd probably be better off caching them, as there's one Java class being generted per JS function.

Scopes - objects created through cx.initStandardObject() are stateful though, you'll need one for each Script.execute() invocation.

Attila.

--
home: http://www.szegedi.org
twitter: http://twitter.com/szegedi
weblog: http://constc.blogspot.com

On 2008.12.09., at 10:26, Johan Compagner wrote:

Hi,

We use rhino also on the server and every http session has its own script
engine (cx.initStandardObjects(null))

But we notice when we have let the scripts compile
(cx.setOptimizationLevel(9)) for very client/http sesssion that we are
running out of perm space
because of the many classes generated (and maybe not cleared fast enough or
hold on to at some point)

now i could build that the compile takes place and caches our scripts once
for every client/session.
But then a (compiled) script can run concurrently with others, so my
question is does a script has internal state like a stack pointer or other
data?
So that this cant really be done?

johan




_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to