Author: xor
Date: 2007-12-23 12:48:49 +0000 (Sun, 23 Dec 2007)
New Revision: 16804

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 11:00:07 UTC (rev 
16803)
+++ trunk/freenet/src/freenet/node/Node.java    2007-12-23 12:48:49 UTC (rev 
16804)
@@ -1251,8 +1251,13 @@
                        public void set(long val) throws 
InvalidConfigValueException {
                                if(val < 0)
                                        throw new 
InvalidConfigValueException(l10n("mustBePositive"));
-                               else if(val > (80 * 
Runtime.getRuntime().maxMemory() / 100))
-                                       throw new 
InvalidConfigValueException(l10n("storeMaxMemTooHigh"));
+                               else {
+                                       long maxHeapMemory = 
Runtime.getRuntime().maxMemory();
+                                       /* There are some JVMs (for example 
libgcj 4.1.1) whose Runtime.maxMemory() does not work. */
+                                       if(maxHeapMemory < Long.MAX_VALUE && 
val > (80 * maxHeapMemory / 100))
+                                               throw new 
InvalidConfigValueException(l10n("storeMaxMemTooHigh"));
+                               }
+                               
                                envMutableConfig.setCacheSize(val);
                                try{
                                        
storeEnvironment.setMutableConfig(envMutableConfig);


Reply via email to