From 2f28a635a9282d29ca80e8ed46fe6b7ddccdba5b Mon Sep 17 00:00:00 2001
From: jrandom <jrandom>
Date: Wed, 11 Aug 2004 22:23:48 +0000
Subject: [PATCH] integrated oOo's memory usage patch (the % shown is
 unfortunately % of peak, not % of max) [thanks oOo!] cleaned up build script
 to make sure we always build fresh JSPs and xml [thanks oOo^2!]

---
 apps/routerconsole/java/build.xml                     |  5 ++++-
 .../java/src/net/i2p/router/web/SummaryHelper.java    | 11 +++++++++++
 apps/routerconsole/jsp/summary.jsp                    |  1 +
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/apps/routerconsole/java/build.xml b/apps/routerconsole/java/build.xml
index b59a4413cc..94de8d185a 100644
--- a/apps/routerconsole/java/build.xml
+++ b/apps/routerconsole/java/build.xml
@@ -28,10 +28,13 @@
     </target>
     <target name="war" depends="precompilejsp">
         <war destfile="build/routerconsole.war" webxml="../jsp/web-out.xml"
-             basedir="../jsp/" excludes="web.xml, *.java, *.jsp">
+             basedir="../jsp/" excludes="web.xml, *.java, *.jsp, web-fragment.xml">
         </war>
     </target>
     <target name="precompilejsp">
+        <delete dir="../jsp/WEB-INF/" />
+        <delete dir="../jsp/web-fragment.xml" />
+        <delete dir="../jsp/web-out.xml" />
         <mkdir dir="../jsp/WEB-INF/" />
         <mkdir dir="../jsp/WEB-INF/classes" />
         <!-- there are various jspc ant tasks, but they all seem a bit flakey -->
diff --git a/apps/routerconsole/java/src/net/i2p/router/web/SummaryHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/SummaryHelper.java
index 9583aaff0a..50ac4ca881 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/SummaryHelper.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/SummaryHelper.java
@@ -64,6 +64,17 @@ public class SummaryHelper {
         else
             return DataHelper.formatDuration(router.getUptime());
     }
+
+        
+    /**
+     * Retrieve amount of used memory.
+     *
+     */
+    public String getMemory() {
+        long used = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())/1024;
+        long usedPc = 100 - ((Runtime.getRuntime().freeMemory() * 100) / Runtime.getRuntime().totalMemory());
+        return used + "KB (" + usedPc + "%)"; 
+    }
     
     /**
      * How many active peers the router has.
diff --git a/apps/routerconsole/jsp/summary.jsp b/apps/routerconsole/jsp/summary.jsp
index 64cda9550a..c0d5103fa1 100644
--- a/apps/routerconsole/jsp/summary.jsp
+++ b/apps/routerconsole/jsp/summary.jsp
@@ -7,6 +7,7 @@
  <b>Ident:</b> <jsp:getProperty name="helper" property="ident" /><br />
  <b>Version:</b> <jsp:getProperty name="helper" property="version" /><br />
  <b>Uptime:</b> <jsp:getProperty name="helper" property="uptime" /><br />
+ <b>Memory:</b> <jsp:getProperty name="helper" property="memory" /><br />
  <hr />
  
  <u><b>Peers</b></u><br />
-- 
GitLab