mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-10 21:31:53 +01:00
[automation] Avoid memory leak on script loading failure (#4162)
Core part of the fix for https://github.com/openhab/openhab-addons/issues/16462. Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
This commit is contained in:
parent
e871dcfa47
commit
be9cbf2649
@ -175,7 +175,13 @@ public class ScriptEngineManagerImpl implements ScriptEngineManager {
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
logger.error("Error during evaluation of script '{}': {}", engineIdentifier, ex.getMessage());
|
||||
logger.debug("", ex);
|
||||
// Only call logger if debug level is actually enabled, because OPS4J Pax Logging holds (at least for
|
||||
// some time) a reference to the exception and its cause, which may hold a reference to the script
|
||||
// engine.
|
||||
// This prevents garbage collection (at least for some time) to remove the script engine from heap.
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user