I'm porting some code from using the JRuby Embed API directly to
JSR-223. The requirement is driven by a desire to loosely couple the
calling code to the JRuby interpreter; if I use any JRuby classes
directly in the caller, I lose the pluggability I need. All works
well, save for this:
Runtimes need to be discarded by the application occasionally. The
application used to do this:
JavaEmbedUtils.terminate(runtime)
... which cleaned everything up fine. But the new application just
abandons Engines, which never go away on their own, and eventually
exhaust memory. I'm pretty sure the javax.scripting API is lacking on
this front. I don't think there's any lifecycle support for Engines at
all. That's kind of OK, since I've got my own OSGi-friendly broker for
returning ScriptEngine instances; it *does* understand lifecycle, and
that's where I need to be able to kill off an engine that is no longer
of any use.
So: anyone know a clever way to tell a JRuby JSR-223 ScriptEngine that
I'm done with it? My only workable idea was to expose a public method
on JRubyEngine, which I think has the underlying Ruby object visible,
to terminate the runtime; I can use reflection to invoke that method
if it exists, without introducing a hard dependency on JRuby.
- Rob
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email