Print memory and thread info to log file to aid debugging and monitoring.
Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2979734
This commit is contained in:
parent
4b2c766803
commit
5fb24d597b
|
@ -251,7 +251,7 @@ public class CLogMgt
|
||||||
if (level == null)
|
if (level == null)
|
||||||
return;
|
return;
|
||||||
LogManager mgr = LogManager.getLogManager();
|
LogManager mgr = LogManager.getLogManager();
|
||||||
Enumeration en = mgr.getLoggerNames();
|
Enumeration<?> en = mgr.getLoggerNames();
|
||||||
while (en.hasMoreElements())
|
while (en.hasMoreElements())
|
||||||
{
|
{
|
||||||
String name = en.nextElement().toString();
|
String name = en.nextElement().toString();
|
||||||
|
@ -498,7 +498,7 @@ public class CLogMgt
|
||||||
Attributes atts = mf.getMainAttributes();
|
Attributes atts = mf.getMainAttributes();
|
||||||
if (atts != null)
|
if (atts != null)
|
||||||
{
|
{
|
||||||
Iterator it = atts.keySet().iterator();
|
Iterator<?> it = atts.keySet().iterator();
|
||||||
while (it.hasNext())
|
while (it.hasNext())
|
||||||
{
|
{
|
||||||
Object key = it.next();
|
Object key = it.next();
|
||||||
|
@ -522,11 +522,39 @@ public class CLogMgt
|
||||||
.append("/").append(Env.isBaseLanguage(Env.getCtx(), "C_UOM")).append(NL);
|
.append("/").append(Env.isBaseLanguage(Env.getCtx(), "C_UOM")).append(NL);
|
||||||
sb.append(Adempiere.getJavaInfo()).append(NL);
|
sb.append(Adempiere.getJavaInfo()).append(NL);
|
||||||
sb.append("java.io.tmpdir="+System.getProperty("java.io.tmpdir")).append(NL);
|
sb.append("java.io.tmpdir="+System.getProperty("java.io.tmpdir")).append(NL);
|
||||||
sb.append(Adempiere.getOSInfo());
|
sb.append(Adempiere.getOSInfo()).append(NL);
|
||||||
|
|
||||||
|
//report memory info
|
||||||
|
Runtime runtime = Runtime.getRuntime();
|
||||||
|
//max heap size
|
||||||
|
sb.append("Max Heap = "+formatMemoryInfo(runtime.maxMemory())).append(NL);
|
||||||
|
//allocated heap size
|
||||||
|
sb.append("Allocated Heap = "+formatMemoryInfo(runtime.totalMemory())).append(NL);
|
||||||
|
//free heap size
|
||||||
|
sb.append("Free Heap = "+formatMemoryInfo(runtime.freeMemory())).append(NL);
|
||||||
|
//
|
||||||
|
//thread info
|
||||||
|
sb.append("Active Threads = " + Thread.activeCount());
|
||||||
//
|
//
|
||||||
return sb;
|
return sb;
|
||||||
} // getInfo
|
} // getInfo
|
||||||
|
|
||||||
|
private static String formatMemoryInfo(long amount)
|
||||||
|
{
|
||||||
|
String unit = "";
|
||||||
|
long size = amount / 1024 ;
|
||||||
|
if (size > 1024)
|
||||||
|
{
|
||||||
|
size = size / 1024;
|
||||||
|
unit = "M";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unit = "K";
|
||||||
|
}
|
||||||
|
return size + unit;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create System Info
|
* Create System Info
|
||||||
* @param sb Optional string buffer
|
* @param sb Optional string buffer
|
||||||
|
|
Loading…
Reference in New Issue