tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kkoli...@apache.org
Subject svn commit: r1161303 - in /tomcat/trunk: java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java webapps/docs/config/listeners.xml
Date Wed, 24 Aug 2011 22:25:03 GMT
Author: kkolinko
Date: Wed Aug 24 22:25:03 2011
New Revision: 1161303

URL: http://svn.apache.org/viewvc?rev=1161303&view=rev
Log:
Forward-port r1159673 and r1159680 from tc7.0.x
Fixes http://issues.apache.org/bugzilla/show_bug.cgi?id=51688
JreMemoryLeakPreventionListener now protects against AWT thread creation. (schultz)

Modified:
    tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
    tomcat/trunk/webapps/docs/config/listeners.xml

Modified: tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java?rev=1161303&r1=1161302&r2=1161303&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java Wed Aug
24 22:25:03 2011
@@ -67,7 +67,19 @@ public class JreMemoryLeakPreventionList
     public void setAppContextProtection(boolean appContextProtection) {
         this.appContextProtection = appContextProtection;
     }
-    
+
+    /**
+     * Protect against the memory leak caused when the first call to
+     * <code>java.awt.Toolkit.getDefaultToolkit()</code> is triggered
+     * by a web application. Defaults to <code>false</code> because a new
+     * Thread is launched.
+     */
+    private boolean awtThreadProtection = false;
+    public boolean isAWTThreadProtection() { return awtThreadProtection; }
+    public void setAWTThreadProtection(boolean awtThreadProtection) {
+      this.awtThreadProtection = awtThreadProtection;
+    }
+
     /**
      * Protect against the memory leak caused when the first call to
      * <code>sun.misc.GC.requestLatency(long)</code> is triggered by a web
@@ -218,7 +230,13 @@ public class JreMemoryLeakPreventionList
                 if (appContextProtection) {
                     ImageIO.getCacheDirectory();
                 }
-                
+
+                // Trigger the creation of the AWT (AWT-Windows, AWT-XAWT,
+                // etc.) thread
+                if (awtThreadProtection) {
+                  java.awt.Toolkit.getDefaultToolkit();
+                }
+
                 /*
                  * Several components end up calling:
                  * sun.misc.GC.requestLatency(long)

Modified: tomcat/trunk/webapps/docs/config/listeners.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/listeners.xml?rev=1161303&r1=1161302&r2=1161303&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/listeners.xml (original)
+++ tomcat/trunk/webapps/docs/config/listeners.xml Wed Aug 24 22:25:03 2011
@@ -174,6 +174,13 @@
         is <code>true</code>.</p>
       </attribute>
 
+      <attribute name="AWTThreadProtection" required="false">
+        <p>Enables protection so that calls to
+        <code>java.awt.Toolkit.getDefaultToolkit()</code> triggered by a web
+        application do not result in a memory leak.
+        Defaults to <code>false</code> because an AWT thread is launched.</p>
+      </attribute>
+
       <attribute name="driverManagerProtection" required="false">
         <p>The first use of <code>java.sql.DriverManager</code> will trigger
the
         loading of JDBNC Driver in the the current class loader. The web



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message