Revision: 4013
http://vexi.svn.sourceforge.net/vexi/?rev=4013&view=rev
Author: jeffbuhrt
Date: 2011-02-01 03:17:56 +0000 (Tue, 01 Feb 2011)
Log Message:
-----------
Added vexi.system.gc() and vexi.system.memoryusage() for application
debugging/development use.
Example usage:
var mem = vexi.system.memoryusage();
vexi.log.info("mem.maxMemory:" + mem.maxMemory);
vexi.log.info("mem.totalMemory:" + mem.totalMemory);
vexi.log.info("mem.freeMemory:" + mem.freeMemory);
vexi.system.gc();
Modified Paths:
--------------
trunk/org.vexi-core.main/src/main/jpp/org/vexi/core/Vexi.jpp
Modified: trunk/org.vexi-core.main/src/main/jpp/org/vexi/core/Vexi.jpp
===================================================================
--- trunk/org.vexi-core.main/src/main/jpp/org/vexi/core/Vexi.jpp
2011-01-31 16:35:30 UTC (rev 4012)
+++ trunk/org.vexi-core.main/src/main/jpp/org/vexi/core/Vexi.jpp
2011-02-01 03:17:56 UTC (rev 4013)
@@ -314,6 +314,7 @@
case "file": return getSub(name);
case "global": return getSub(name);
case "thread": return getSub(name);
+ case "system": return getSub(name);
case "net": return getSub(name);
case "net.rpc": return getSub(name);
case "ui": return getSub(name);
@@ -407,6 +408,16 @@
* @return(null) */
case "thread.yield": return METHOD;
+ /* Calls JVM's gc()
+ * @method
+ * @return(null) */
+ case "system.gc": return METHOD;
+
+ /* Returns Java's current: maxMemory, totalMemory, freeMemory
respectively in KB
+ * @method
+ * @return(null) */
+ case "system.memoryusage": return METHOD;
+
/* Logs its arguments by first passing them to stringify then
formatting the resultant
* strings so they are human readable
* @method
@@ -683,6 +694,20 @@
//#switch(JSU.toString(method))
case "exit": Main.exit(); return null;
case "thread.yield": Main.SCHEDULER.sleep(-1); return null;
+ case "system.gc": System.gc(); return null;
+ case "system.memoryusage":
+ Runtime r = Runtime.getRuntime();
+
+ long freeMem = r.freeMemory() / 1024;
+ long maxMem = r.maxMemory() / 1024;
+ long totalMem = r.totalMemory() / 1024;
+
+ JS ret = new JS.Obj();
+ ret.put(JSU.S("maxMemory"), JSU.N(maxMem));
+ ret.put(JSU.S("totalMemory"), JSU.N(totalMem));
+ ret.put(JSU.S("freeMemory"), JSU.N(freeMem));
+ return ret;
+
//#end
break;
case 1:
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn