You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@depot.apache.org by aj...@apache.org on 2004/06/02 14:48:55 UTC

svn commit: rev 20755 - in incubator/depot/trunk/common/src/java/org/apache/depot/common/util: . debug

Author: ajack
Date: Wed Jun  2 07:48:54 2004
New Revision: 20755

Modified:
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/SystemUtils.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/debug/DebugUtils.java
Log:
Add some memory (usage) debugging.


Modified: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/SystemUtils.java
==============================================================================
--- incubator/depot/trunk/common/src/java/org/apache/depot/common/util/SystemUtils.java	(original)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/SystemUtils.java	Wed Jun  2 07:48:54 2004
@@ -91,4 +91,14 @@
 		//:TODO: Singleton?
 		return new PrintWriter(System.err, true);
 	}
+	
+	public static Triple getMemoryInformation() {
+		Runtime r = Runtime.getRuntime();
+		
+		Long total = new Long(r.totalMemory());
+		Long free = new Long(r.freeMemory());
+		Long max = new Long(r.maxMemory());
+		
+		return new Triple(total,free,max);
+	}
 }

Modified: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/debug/DebugUtils.java
==============================================================================
--- incubator/depot/trunk/common/src/java/org/apache/depot/common/util/debug/DebugUtils.java	(original)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/debug/DebugUtils.java	Wed Jun  2 07:48:54 2004
@@ -24,7 +24,9 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.depot.common.log.Logger;
 import org.apache.depot.common.util.SystemUtils;
+import org.apache.depot.common.util.Triple;
 
 /**
  * @version $Revision: $
@@ -425,5 +427,25 @@
 			out.print(indent);
 			out.println("No Map.");
 		}
+	}
+	
+	public static void logMemoryInformation() {
+		
+		Triple info = SystemUtils.getMemoryInformation();
+		
+		StringBuffer minfo = new StringBuffer();
+
+		minfo.append("Memory Info: ");
+		minfo.append("Total: ");
+		minfo.append(info.getFirst());
+		minfo.append(", Free: ");
+		minfo.append(info.getSecond());
+		minfo.append(", Max: ");
+		minfo.append(info.getThird());
+		minfo.append(".");
+
+		String message = minfo.toString();
+		Logger.getLogger().info(message);
+		System.out.println(message);		
 	}
 }