Skip to content

Using JSR223 ScriptEngine interface has no way to clean up resources #8690

@ccutrer

Description

@ccutrer

Expected Behavior

I embed JRuby into openHAB, using the JSR223 interface (since that's how openHAB handles several different scripting languages). A new ScriptEngine is created for each script, including if it's reloaded because I've changed it. openHAB's core code that manages scripts will check if the ScriptEngine implements AutoCloseable when it's unloading a script, and call close() on it if it does. But JRubyEngine doesn't implement AutoCloseable, nor does it have any way to access the ScriptingContainer in order for me to call terminate myself. I would expect it to implement AutoCloseable, and calling close() on the engine will just call container.terminate().

Actual Behavior

When I reload a lot of scripts, my memory usage goes up, and eventually I get to the point where GC is using 100% CPU because it's having such a hard time freeing up resources from old engines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions