[jboss-cvs] JBossAS SVN: r81818 - trunk/testsuite/src/main/org/jboss/test/classloader/leak/clstore.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Nov 29 23:22:14 EST 2008


Author: bstansberry at jboss.com
Date: 2008-11-29 23:22:14 -0500 (Sat, 29 Nov 2008)
New Revision: 81818

Modified:
   trunk/testsuite/src/main/org/jboss/test/classloader/leak/clstore/ClassLoaderStore.java
Log:
Revert inadvertent commit

Modified: trunk/testsuite/src/main/org/jboss/test/classloader/leak/clstore/ClassLoaderStore.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/classloader/leak/clstore/ClassLoaderStore.java	2008-11-30 04:19:58 UTC (rev 81817)
+++ trunk/testsuite/src/main/org/jboss/test/classloader/leak/clstore/ClassLoaderStore.java	2008-11-30 04:22:14 UTC (rev 81818)
@@ -29,7 +29,6 @@
 import java.io.ObjectOutputStream;
 import java.io.PrintStream;
 import java.io.Serializable;
-//import java.lang.ref.SoftReference;
 import java.lang.ref.WeakReference;
 import java.util.HashMap;
 import java.util.Map;
@@ -42,7 +41,7 @@
    
    private static ClassLoaderStore instance = new ClassLoaderStore();
    
-   private final Map<String, WeakReference<ClassLoader>> classloaders = new HashMap<String, WeakReference<ClassLoader>>();
+   private final Map classloaders = new HashMap();
 
    private final int depth = Integer.parseInt(System.getProperty("jboss.classloader.leak.test.depth", "12"));
 
@@ -65,14 +64,14 @@
          log.debug("Parent is " + parent);
          parent = parent.getParent();
       }
-      WeakReference<ClassLoader> ref = new WeakReference<ClassLoader>(loader);
+      WeakReference ref = new WeakReference(loader);
       classloaders.put(key, ref);
    }
    
    public ClassLoader getClassLoader(String key, boolean forceGC, String reportFile)
    {
       ClassLoader result = null;
-      WeakReference<ClassLoader> ref = classloaders.get(key);
+      WeakReference ref = (WeakReference) classloaders.get(key);
       if (ref != null)
       {
          result = (ClassLoader) ref.get();
@@ -102,7 +101,7 @@
     * @param reportHTMLFile the report file 
     * @throws Exception
     */
-   private ClassLoader getClassLoader(WeakReference<ClassLoader> weakReferenceOnLoader, String reportHTMLFile) throws Exception
+   private ClassLoader getClassLoader(WeakReference weakReferenceOnLoader, String reportHTMLFile) throws Exception
    {
       LeakAnalyzer leakAnalyzer = null;
       try
@@ -144,7 +143,6 @@
          
          Thread.sleep(20);
             
-         @SuppressWarnings("unchecked")
          HashMap datapoints = leakAnalyzer.createIndexMatrix();
          
          if (weakReferenceOnLoader.get() == null)
@@ -174,7 +172,6 @@
       {
          log.debug("JVMTI not active; using System.gc()");
          System.gc();
-         System.runFinalization();
          Thread.sleep(1000);
          
          if (weakReferenceOnLoader.get() != null)
@@ -187,7 +184,7 @@
       return (ClassLoader) weakReferenceOnLoader.get();
    }
    
-   private void fillMemory(WeakReference<ClassLoader> ref)
+   private void fillMemory(WeakReference ref)
    {
       Runtime rt = Runtime.getRuntime();
       int[] adds = { 0, 10, 20, 30, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49 };
@@ -213,29 +210,13 @@
           {
              byte[][] bytez =  new byte[1000][];
              for (int j = 0; j < bytez.length; j++)
-             { 
                 bytez[j] = new byte[bucket];
-                if (j % 100 == 0)
-                {  
-                   // Sleep a bit to allow CPU to do other work
-                   try
-                   {
-                      Thread.sleep(10);
-                   }
-                   catch (InterruptedException ie)
-                   {
-                     log.warn("Interrupted");
-                     Thread.currentThread().interrupt();
-                     break;
-                   }                   
-                }
-             }
           }
           catch (Throwable t)
           {
+             log.warn("Caught throwable filling memory: " + t);
              System.gc();
              System.runFinalization();
-             log.warn("Caught throwable filling memory: " + t);
              break;
           }       
           finally
@@ -243,37 +224,33 @@
              // Sleep a bit to allow CPU to do work like exchange cluster PING responses
              try
              {
-                Thread.sleep(250);
+                Thread.sleep(20);
              }
-             catch (InterruptedException ie)
+             catch (InterruptedException ignored)
              {
                log.warn("Interrupted");
-               Thread.currentThread().interrupt();
                break;
              }
           }
       }
       
-      if (ref.get() != null)
+      try
       {
-         try
-         {
-            ByteArrayOutputStream byteout = new ByteArrayOutputStream();
-            ObjectOutputStream out = new ObjectOutputStream(byteout);
-           
-            out.writeObject(new Dummy());
-            out.close();
-            
-            ByteArrayInputStream byteInput = new ByteArrayInputStream(byteout.toByteArray());
-            ObjectInputStream input = new ObjectInputStream(byteInput);
-            input.readObject();
-            input.close();
-         }
-         catch (Exception e)
-         {
-            e.printStackTrace();
-         }
+         ByteArrayOutputStream byteout = new ByteArrayOutputStream();
+         ObjectOutputStream out = new ObjectOutputStream(byteout);
+        
+         out.writeObject(new Dummy());
+         out.close();
+         
+         ByteArrayInputStream byteInput = new ByteArrayInputStream(byteout.toByteArray());
+         ObjectInputStream input = new ObjectInputStream(byteInput);
+         input.readObject();
+         input.close();
       }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
       
       if (ref.get() != null)
       {
@@ -292,73 +269,4 @@
    {
         private static final long serialVersionUID = 1L;
    }
-   
-//   public static void main(String[] args)
-//   {
-//      SoftReference softRef = new SoftReference(new Object());
-//      byte[][] bytez = new byte[1000][];
-//      try
-//      {
-//         long max = Runtime.getRuntime().maxMemory();
-//         
-//         for (int i = 0; i < bytez.length; i++)
-//         {            
-//            long avail = Runtime.getRuntime().freeMemory();
-//            System.out.println(i + " Adding bytes: " + avail / 100);
-//            bytez[i] = new byte[(int) (avail / 100)];
-//            if (i % 10 == 0)
-//            { 
-//               // Sleep a bit to allow CPU to do other work
-//               try
-//               {
-//                  System.out.println("resting");
-//                  Thread.sleep(100);
-//               }
-//               catch (InterruptedException ie)
-//               {
-//                 log.warn("Interrupted");
-//                 Thread.currentThread().interrupt();
-//                 break;
-//               }
-//               
-//            } 
-//            
-//            if (i % 100 == 0 || max / avail > 20)
-//            {
-//               System.out.println("running");
-//               System.gc();
-//               System.runFinalization();
-//            }
-//            
-//            if (softRef.get() == null)
-//            {
-//               System.out.println("released");
-//            }
-//         }
-//      }
-//      catch (Throwable t)
-//      {
-//         System.gc();
-//         System.runFinalization();
-//         System.out.println("Caught throwable filling memory: " + t);
-//      }       
-//      finally
-//      {
-//         // Sleep a bit to allow CPU to do work like exchange cluster PING responses
-//         try
-//         {
-//            Thread.sleep(250);
-//         }
-//         catch (InterruptedException ie)
-//         {
-//           System.out.println("Interrupted");
-//           Thread.currentThread().interrupt();
-//         }
-//      }
-//      
-//      if (softRef.get() == null)
-//      {
-//         System.out.println("released");
-//      }
-//   }
 }




More information about the jboss-cvs-commits mailing list