incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chet...@apache.org
Subject svn commit: r1567043 - /sling/trunk/contrib/extensions/leak-detector/src/main/java/org/apache/sling/extensions/leakdetector/internal/LeakDetector.java
Date Tue, 11 Feb 2014 10:57:10 GMT
Author: chetanm
Date: Tue Feb 11 10:57:09 2014
New Revision: 1567043

URL: http://svn.apache.org/r1567043
Log:
SLING-3359 - Classloader Leak Detector Console Tab

Adding a help message incase the JVM is not started with required VM options

Modified:
    sling/trunk/contrib/extensions/leak-detector/src/main/java/org/apache/sling/extensions/leakdetector/internal/LeakDetector.java

Modified: sling/trunk/contrib/extensions/leak-detector/src/main/java/org/apache/sling/extensions/leakdetector/internal/LeakDetector.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/leak-detector/src/main/java/org/apache/sling/extensions/leakdetector/internal/LeakDetector.java?rev=1567043&r1=1567042&r2=1567043&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/leak-detector/src/main/java/org/apache/sling/extensions/leakdetector/internal/LeakDetector.java
(original)
+++ sling/trunk/contrib/extensions/leak-detector/src/main/java/org/apache/sling/extensions/leakdetector/internal/LeakDetector.java
Tue Feb 11 10:57:09 2014
@@ -1,6 +1,8 @@
 package org.apache.sling.extensions.leakdetector.internal;
 
 import java.io.PrintWriter;
+import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
 import java.lang.ref.PhantomReference;
 import java.lang.ref.Reference;
 import java.lang.ref.ReferenceQueue;
@@ -196,6 +198,27 @@ public class LeakDetector implements Run
                 }
             }
         }
+        pw.println();
+
+        addHelp(pw);
+    }
+
+    private static void addHelp(PrintWriter pw){
+        RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
+        List<String> argList = bean.getInputArguments();
+
+        boolean containsRequiredArgs = argList.contains("-XX:+UseConcMarkSweepGC")
+                && argList.contains("-XX:+CMSClassUnloadingEnabled");
+
+        if(!containsRequiredArgs){
+            pw.println("Required VM Options Missing");
+            pw.println("===========================");
+            pw.println("Leak detector relies on garbage collection of classloaders. By default");
+            pw.println("the classloaders are not garbage collected. To enable garbage collection
of");
+            pw.println("classloader start the JVM with following options ");
+            pw.println("");
+            pw.println("    -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled");
+        }
     }
 
     //~---------------------------------------<Data Model>



Mime
View raw message