プロジェクトで Rhino を使用しています。このプロジェクトでは、短時間使用されてから破棄される ScriptableObjects を多数作成する必要があります。これを行うと、メモリリークが発生しますか?
コードは次のようなものです。
Context cx = ContextFactory.getGlobal.enter();
try {
for (String script : Scripts.findAll()) {
Scriptable scope = cx.initStandardObjects();
// load script into scope, and do something with it.
// do I need to do any cleanup to for the scope?
}
} finally {
Context.exit();
}
マルコの解決策は良いものです。jvisualvm でシナリオをテストしたところ、ガベージ コレクションによって問題が解決されたことがわかりました。