From e614b0996d4430399b48e3cd72d250d657ac0b1e Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Tue, 8 Nov 2016 15:42:22 +0000 Subject: [PATCH] Router: Fix low-memory log messages for non-wrapper (ticket #1795) Install: Add max memory option to runplain.sh Build: Fix minimum Java version for Windows --- installer/i2pinstaller.xml | 2 +- installer/i2pstandalone.xml | 2 +- installer/resources/runplain.sh | 8 +++++-- .../src/net/i2p/router/tasks/OOMListener.java | 22 +++++++++++------- .../router/tunnel/BloomFilterIVValidator.java | 23 ++++++++++++------- 5 files changed, 37 insertions(+), 20 deletions(-) diff --git a/installer/i2pinstaller.xml b/installer/i2pinstaller.xml index 84edded227..62912b8284 100644 --- a/installer/i2pinstaller.xml +++ b/installer/i2pinstaller.xml @@ -7,7 +7,7 @@ <customProcName>false</customProcName> <icon>resources/console.ico</icon> <jre> - <minVersion>1.6.0</minVersion> + <minVersion>1.7.0</minVersion> </jre> <!-- <splash> diff --git a/installer/i2pstandalone.xml b/installer/i2pstandalone.xml index 8b92ed21ee..71e338dd92 100644 --- a/installer/i2pstandalone.xml +++ b/installer/i2pstandalone.xml @@ -7,7 +7,7 @@ <customProcName>false</customProcName> <icon>resources/start.ico</icon> <jre> - <minVersion>1.6.0</minVersion> + <minVersion>1.7.0</minVersion> <!-- <minHeapSize>64</minHeapSize> --> diff --git a/installer/resources/runplain.sh b/installer/resources/runplain.sh index f1bf81d810..eb4995dfed 100644 --- a/installer/resources/runplain.sh +++ b/installer/resources/runplain.sh @@ -3,7 +3,7 @@ # This runs the router by itself, WITHOUT the wrapper. # This means the router will not restart if it crashes. # Also, you will be using the default memory size, which is -# probably not enough for i2p. +# probably not enough for i2p, unless you set it below. # You should really use the i2prouter script instead. # @@ -19,6 +19,10 @@ I2PTEMP="%SYSTEM_java_io_tmpdir" PREFERv4="false" CP= +# Uncomment to set the maximum memory. The default and the option may vary in different JVMs. +# Check your java documentation to be sure. +#MAXMEMOPT="-Xmx256m" + # Try using the Java binary that I2P was installed with. # If it's not found, try looking in the system PATH. JAVA=$(which %JAVA_HOME/bin/java || which java) @@ -39,7 +43,7 @@ done if [ $(uname -s) = "Darwin" ]; then export JAVA_TOOL_OPTIONS="-Djava.awt.headless=true" fi -JAVAOPTS="-Djava.net.preferIPv4Stack=${PREFERv4} -Djava.library.path=${I2P}:${I2P}/lib -Di2p.dir.base=${I2P} -DloggerFilenameOverride=logs/log-router-@.txt" +JAVAOPTS="${MAXMEMOPT} -Djava.net.preferIPv4Stack=${PREFERv4} -Djava.library.path=${I2P}:${I2P}/lib -Di2p.dir.base=${I2P} -DloggerFilenameOverride=logs/log-router-@.txt" ( nohup ${JAVA} -cp \"${CP}\" ${JAVAOPTS} net.i2p.router.RouterLaunch > /dev/null 2>&1 ) & diff --git a/router/java/src/net/i2p/router/tasks/OOMListener.java b/router/java/src/net/i2p/router/tasks/OOMListener.java index 3aa2c08661..ed2050a390 100644 --- a/router/java/src/net/i2p/router/tasks/OOMListener.java +++ b/router/java/src/net/i2p/router/tasks/OOMListener.java @@ -49,17 +49,23 @@ public class OOMListener implements I2PThread.OOMEventListener { log.log(Log.CRIT, "Thread ran out of memory, shutting down I2P", oom); log.log(Log.CRIT, "free mem: " + Runtime.getRuntime().freeMemory() + " total mem: " + Runtime.getRuntime().totalMemory()); + // Can't find any System property or wrapper property that gives + // you the actual config file path, have to guess + String path; + if (SystemVersion.isLinuxService()) { + path = "/etc/i2p"; + } else { + path = _context.getBaseDir().toString(); + } if (_context.hasWrapper()) { - // Can't find any System property or wrapper property that gives - // you the actual config file path, have to guess - String path; - if (SystemVersion.isLinuxService()) { - path = "/etc/i2p"; - } else { - path = _context.getBaseDir().toString(); - } log.log(Log.CRIT, "To prevent future shutdowns, increase wrapper.java.maxmemory in " + path + File.separatorChar + "wrapper.config"); + } else if (!SystemVersion.isWindows()) { + log.log(Log.CRIT, "To prevent future shutdowns, increase MAXMEMOPT in " + + path + File.separatorChar + "runplain.sh or /usr/bin/i2prouter-nowrapper"); + } else { + log.log(Log.CRIT, "To prevent future shutdowns, run the restartable version of I2P, and increase wrapper.java.maxmemory in " + + path + File.separatorChar + "wrapper.config"); } } catch (OutOfMemoryError oome) {} try { diff --git a/router/java/src/net/i2p/router/tunnel/BloomFilterIVValidator.java b/router/java/src/net/i2p/router/tunnel/BloomFilterIVValidator.java index f96bdfece2..61a52e2a35 100644 --- a/router/java/src/net/i2p/router/tunnel/BloomFilterIVValidator.java +++ b/router/java/src/net/i2p/router/tunnel/BloomFilterIVValidator.java @@ -104,7 +104,6 @@ class BloomFilterIVValidator implements IVValidator { return; // Can't find any System property or wrapper property that gives // you the actual config file path, have to guess - // TODO if !SystemVersion.hasWrapper ... String path; if (SystemVersion.isLinuxService()) { path = "/etc/i2p"; @@ -114,13 +113,21 @@ class BloomFilterIVValidator implements IVValidator { String msg = "Configured for " + DataHelper.formatSize(KBps *1024L) + "Bps share bandwidth but only " + - DataHelper.formatSize(maxMemory) + "B available memory." + - " Recommend increasing wrapper.java.maxmemory in " + - path + File.separatorChar + "wrapper.config" + - // getMaxMemory() returns significantly lower than wrapper config, so add 10% - " to at least " + (recMaxMem * 11 / 10 / (1024*1024)) + " (MB)" + - " if the actual share bandwidth exceeds " + - DataHelper.formatSize(threshKBps * 1024L) + "Bps."; + DataHelper.formatSize(maxMemory) + "B available memory."; + if (_context.hasWrapper()) { + msg += " Recommend increasing wrapper.java.maxmemory in " + + path + File.separatorChar + "wrapper.config"; + } else if (!SystemVersion.isWindows()) { + msg += " Recommend increasing MAXMEMOPT in " + + path + File.separatorChar + "runplain.sh or /usr/bin/i2prouter-nowrapper"; + } else { + msg += " Recommend running the restartable version of I2P, and increasing wrapper.java.maxmemory in " + + path + File.separatorChar + "wrapper.config"; + } + // getMaxMemory() returns significantly lower than wrapper config, so add 10% + msg += " to at least " + (recMaxMem * 11 / 10 / (1024*1024)) + " (MB)" + + " if the actual share bandwidth exceeds " + + DataHelper.formatSize(threshKBps * 1024L) + "Bps."; System.out.println("WARN: " + msg); _context.logManager().getLog(BloomFilterIVValidator.class).logAlways(Log.WARN, msg); } -- GitLab