Author: schultz
Date: Tue Sep 20 20:17:23 2011
New Revision: 1173333
URL: http://svn.apache.org/viewvc?rev=1173333&view=rev
Log:
Fixed bug #51687: Improve JreMemoryLeakPreventionListener against leak caused
by sun.java2d.Disposer
- Added (optional) protection against sun.java2d.Disposer thread pinning a
WebappClassLoader into memory in the JreMemoryLeakPreventionListener.
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=1173333&r1=1173332&r2=1173333&view=diff
==============================================================================
---
tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
(original)
+++
tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
Tue Sep 20 20:17:23 2011
@@ -81,6 +81,19 @@ public class JreMemoryLeakPreventionList
}
/**
+ * Protect against the memory leak caused when the
+ * <code>sun.java2d.Disposer</code> class is loaded by a web application.
+ * Defaults to <code>false</code> because a new Thread is launched.
+ */
+ private boolean java2dDisposerProtection = false;
+ public boolean isJava2DDisposerProtection() {
+ return java2dDisposerProtection;
+ }
+ public void setJava2DDisposerProtection(boolean java2dDisposerProtection) {
+ this.java2dDisposerProtection = java2dDisposerProtection;
+ }
+
+ /**
* Protect against the memory leak caused when the first call to
* <code>sun.misc.GC.requestLatency(long)</code> is triggered by a web
* application. This first call will start a GC Daemon thread with the
@@ -237,6 +250,18 @@ public class JreMemoryLeakPreventionList
java.awt.Toolkit.getDefaultToolkit();
}
+ // Trigger the creation of the "Java2D Disposer" thread.
+ // See https://issues.apache.org/bugzilla/show_bug.cgi?id=51687
+ if(java2dDisposerProtection) {
+ try {
+ Class.forName("sun.java2d.Disposer");
+ }
+ catch (ClassNotFoundException cnfe) {
+ // Ignore this case: we must be running on a
+ // non-Sun-based JRE.
+ }
+ }
+
/*
* 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=1173333&r1=1173332&r2=1173333&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/listeners.xml (original)
+++ tomcat/trunk/webapps/docs/config/listeners.xml Tue Sep 20 20:17:23 2011
@@ -199,6 +199,13 @@
startup on non-Sun JVMs. The default is <code>true</code>.</p>
</attribute>
+ <attribute name="java2DDisposerProtection" required="false">
+ <p>Enables protection so that loading the
+ <code>sun.java2d.Disposer</code> class by a web application does not
+ result in a memory leak.
+ Defaults to <code>false</code> because a thread is launched.</p>
+ </attribute>
+
<attribute name="ldapPoolProtection" required="false">
<p>Enables protection so that the PoolCleaner thread started by
<code>com.sun.jndi.ldap.LdapPoolManager</code> does not result in a
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]