[jboss-cvs] JBoss Messaging SVN: r7734 - trunk/src/main/org/jboss/messaging/core/server/impl.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Aug 14 13:04:22 EDT 2009


Author: timfox
Date: 2009-08-14 13:04:22 -0400 (Fri, 14 Aug 2009)
New Revision: 7734

Modified:
   trunk/src/main/org/jboss/messaging/core/server/impl/MemoryManagerImpl.java
Log:
fixed calculation again

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MemoryManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MemoryManagerImpl.java	2009-08-14 16:50:04 UTC (rev 7733)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MemoryManagerImpl.java	2009-08-14 17:04:22 UTC (rev 7734)
@@ -145,20 +145,22 @@
             
             long freeMemory = runtime.freeMemory();
             
-            double currentFreeMemoryPercent = 100.0 * freeMemory / maxMemory;
+            long availableMemory = freeMemory + (maxMemory - totalMemory);
+                                    
+            double availableMemoryPercent = 100.0 * (double)availableMemory / maxMemory;
             
             String info = "";
             info += String.format("free memory:      %s\n", SizeFormatterUtil.sizeof(freeMemory));
             info += String.format("max memory:       %s\n", SizeFormatterUtil.sizeof(maxMemory));
             info += String.format("total memory:     %s\n", SizeFormatterUtil.sizeof(totalMemory));
-            info += String.format("available memory: %.2f%%\n", currentFreeMemoryPercent);
+            info += String.format("available memory: %.2f%%\n", availableMemoryPercent);
 
             if (log.isDebugEnabled())
             {
                log.debug(info);
             }
             
-            if (currentFreeMemoryPercent <= freeMemoryPercent)
+            if (availableMemoryPercent <= freeMemoryPercent)
             {
                log.warn("Less than " + freeMemoryPercent + "%\n" 
                         + info +




More information about the jboss-cvs-commits mailing list