Author: xor
Date: 2007-12-23 13:07:07 +0000 (Sun, 23 Dec 2007)
New Revision: 16805

Modified:
   trunk/freenet/src/freenet/node/Node.java
Log:
Fix usage of Runtime.getRuntime().maxMemory(), in addition to rev. 16802.

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2007-12-23 12:48:49 UTC (rev 
16804)
+++ trunk/freenet/src/freenet/node/Node.java    2007-12-23 13:07:07 UTC (rev 
16805)
@@ -1269,9 +1269,11 @@

                });

+               /* There are some JVMs (for example libgcj 4.1.1) whose 
Runtime.maxMemory() does not work. */
+               long maxHeapMemory = Runtime.getRuntime().maxMemory();
                databaseMaxMemory = nodeConfig.getLong("databaseMaxMemory");
                // see #1202
-               if(databaseMaxMemory > (80 * Runtime.getRuntime().maxMemory() / 
100)){
+               if(maxHeapMemory < Long.MAX_VALUE && databaseMaxMemory > (80 * 
maxHeapMemory / 100)){
                        Logger.error(this, "The databaseMemory setting is set 
too high " + databaseMaxMemory +
                                        " ... let's assume it's not what the 
user wants to do and restore the default.");
                        databaseMaxMemory = Long.valueOf(((LongOption) 
nodeConfig.getOption("databaseMaxMemory")).getDefault()).longValue();


Reply via email to