diff --git a/router/java/src/net/i2p/router/Router.java b/router/java/src/net/i2p/router/Router.java index 11b0274c6ed889513e5c453ccc09cb5fc080c0ba..236fe0be7417a3ad9915d89cb7970c242c25818b 100644 --- a/router/java/src/net/i2p/router/Router.java +++ b/router/java/src/net/i2p/router/Router.java @@ -766,6 +766,9 @@ public class Router implements RouterClock.ClockShiftListener { * NOT to be called by others, use shutdown(). */ public void shutdown2(int exitCode) { + // help us shut down esp. after OOM + int priority = (exitCode == EXIT_OOM) ? Thread.MAX_PRIORITY - 1 : Thread.NORM_PRIORITY + 2; + Thread.currentThread().setPriority(priority); _shutdownInProgress = true; _log.log(Log.CRIT, "Starting final shutdown(" + exitCode + ')'); // So we can get all the way to the end diff --git a/router/java/src/net/i2p/router/tasks/OOMListener.java b/router/java/src/net/i2p/router/tasks/OOMListener.java index a9650c7bd2043d61e849217c2986dced3617d2c2..6fc9b92cded589b68984105ba2ea98932004b1d8 100644 --- a/router/java/src/net/i2p/router/tasks/OOMListener.java +++ b/router/java/src/net/i2p/router/tasks/OOMListener.java @@ -18,6 +18,8 @@ public class OOMListener implements I2PThread.OOMEventListener { } public void outOfMemory(OutOfMemoryError oom) { + // boost priority to help us shut down + Thread.currentThread().setPriority(Thread.MAX_PRIORITY - 1); Router.clearCaches(); Log log = _context.logManager().getLog(Router.class); log.log(Log.CRIT, "Thread ran out of memory, shutting down I2P", oom);