Revision: 2779
          http://vexi.svn.sourceforge.net/vexi/?rev=2779&view=rev
Author:   mkpg2
Date:     2008-01-31 10:18:33 -0800 (Thu, 31 Jan 2008)

Log Message:
-----------
Feature. Memory leak hunting
   - dump the stack traces of created objects in descending order of their 
frequencies
   - show the reference chain from a static root to the leak

Modified Paths:
--------------
    trunk/core/org.ibex.js/src/org/ibex/js/JS.jpp
    trunk/core/org.ibex.js/src/org/ibex/js/JSExn.java
    trunk/core/org.ibex.js/src/org/ibex/js/JSU.jpp

Modified: trunk/core/org.ibex.js/src/org/ibex/js/JS.jpp
===================================================================
--- trunk/core/org.ibex.js/src/org/ibex/js/JS.jpp       2008-01-31 18:18:07 UTC 
(rev 2778)
+++ trunk/core/org.ibex.js/src/org/ibex/js/JS.jpp       2008-01-31 18:18:33 UTC 
(rev 2779)
@@ -176,8 +176,15 @@
     }
 
     public static class Obj extends Basket.Hash implements Cloneable {
-       public Obj() { super(3, 4, 0.75F); }
+       public Obj() { 
+               super(3, 4, 0.75F); 
+               if(JSU.devl!=null) JSU.devl.register(this);
+       }
 
+       protected void finalize() throws Throwable {
+               if(JSU.devl!=null) JSU.devl.unregister(this);
+       }
+       
         public JS unclone() { return this; }
         public String[] getFormalArgs() { return EMPTY_STRING_ARRAY; }
 

Modified: trunk/core/org.ibex.js/src/org/ibex/js/JSExn.java
===================================================================
--- trunk/core/org.ibex.js/src/org/ibex/js/JSExn.java   2008-01-31 18:18:07 UTC 
(rev 2778)
+++ trunk/core/org.ibex.js/src/org/ibex/js/JSExn.java   2008-01-31 18:18:33 UTC 
(rev 2779)
@@ -15,7 +15,7 @@
     /** Maximum number of entries to report in a backtrace. */
     public static final int MAX_BACKTRACE_SIZE = 20;
 
-    private Basket.List backtrace = new Basket.Array();
+    Basket.List backtrace = new Basket.Array();
     private ExnJSObj js = null;
     public JSExn(Exception e) {
        super(e);

Modified: trunk/core/org.ibex.js/src/org/ibex/js/JSU.jpp
===================================================================
--- trunk/core/org.ibex.js/src/org/ibex/js/JSU.jpp      2008-01-31 18:18:07 UTC 
(rev 2778)
+++ trunk/core/org.ibex.js/src/org/ibex/js/JSU.jpp      2008-01-31 18:18:33 UTC 
(rev 2779)
@@ -1,11 +1,10 @@
 package org.ibex.js;
 
-import java.io.Reader;
+import java.awt.event.KeyEvent;
 import java.io.IOException;
 import java.io.InputStream;
 
 import org.ibex.js.JS.Enumeration;
-import org.ibex.js.JS.Keys;
 import org.ibex.util.*;
 
 public class JSU implements Constants{
@@ -223,7 +222,7 @@
     /////////////
     // JSON
     //////////    
-    static JS json_marshal(JS value) throws JSExn{
+    static public JS json_marshal(JS value) throws JSExn{
         StringBuffer sb=new StringBuffer();
         json_marshal(sb,value);
         return JSU.S(sb.toString());
@@ -331,4 +330,18 @@
         if (op < 0) return ByteCodes.bytecodeToString[-op];
         else return Tokens.codeToString[op];
     }
+    
+    // Set by org.vexi.devl 
+       static public Devl devl = null;
+       static public interface Devl extends JS{
+               public void interceptKeyPress(KeyEvent k);
+               public void register(Object o);
+               public void unregister(Object o);
+               public void dumpStacks();
+       }
+
+    
+    static public Basket.List backtrace(){
+       return new JSExn("").backtrace;
+    }
 }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to