Display VM Heap sizes in Admin System Properties.

Sort System Properties.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2065 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2006-01-03 13:24:32 +00:00
parent d127610611
commit 5b49e7f3af

View File

@@ -17,6 +17,7 @@
package org.alfresco.web.ui.common.component.debug;
import java.util.Map;
import java.util.TreeMap;
/**
* Component which displays the system properties of the VM
@@ -36,8 +37,34 @@ public class UISystemProperties extends BaseDebugComponent
/**
* @see org.alfresco.web.ui.common.component.debug.BaseDebugComponent#getDebugData()
*/
@SuppressWarnings("unchecked")
public Map getDebugData()
{
return System.getProperties();
// note: sort properties
Map properties = new TreeMap();
// add the jvm system properties
Map systemProperties = System.getProperties();
properties.putAll(systemProperties);
// add heap size properties
properties.put("heap.size", formatBytes(Runtime.getRuntime().totalMemory()));
properties.put("heap.maxsize", formatBytes(Runtime.getRuntime().maxMemory()));
properties.put("heap.free", formatBytes(Runtime.getRuntime().freeMemory()));
return properties;
}
/**
* Helper to format bytes for human output
*
* @param bytes bytes
* @return formatted string
*/
private static String formatBytes(long bytes)
{
float f = bytes / 1024l;
f = f / 1024l;
return String.format("%.3f MB (%d bytes)", f, bytes);
}
}