mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-25 11:45:49 +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;
|
return true;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.error("Error during evaluation of script '{}': {}", engineIdentifier, ex.getMessage());
|
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;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user