Author: rjung
Date: Fri May 14 17:31:50 2010
New Revision: 944349
URL: http://svn.apache.org/viewvc?rev=944349&view=rev
Log:
Preparation be fore adding a new leak prevention feature:
change order of features to alphabetic like in listener docs.
Makes checking easier.
Modified:
tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
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=944349&r1=944348&r2=944349&view=diff
==============================================================================
---
tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
(original)
+++
tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
Fri May 14 17:31:50 2010
@@ -66,6 +66,19 @@ public class JreMemoryLeakPreventionList
public void setAppContextProtection(boolean appContextProtection) {
this.appContextProtection = appContextProtection;
}
+
+ /**
+ * 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
+ * thread's context class loader configured to be the web application class
+ * loader. Defaults to <code>true</code>.
+ */
+ private boolean gcDaemonProtection = true;
+ public boolean isGcDaemonProtection() { return gcDaemonProtection; }
+ public void setGcDaemonProtection(boolean gcDaemonProtection) {
+ this.gcDaemonProtection = gcDaemonProtection;
+ }
/**
* Protect against resources being read for JAR files and, as a
side-effect,
@@ -92,19 +105,6 @@ public class JreMemoryLeakPreventionList
this.xmlParsingProtection = xmlParsingProtection;
}
- /**
- * 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
- * thread's context class loader configured to be the web application class
- * loader. Defaults to <code>true</code>.
- */
- private boolean gcDaemonProtection = true;
- public boolean isGcDaemonProtection() { return gcDaemonProtection; }
- public void setGcDaemonProtection(boolean gcDaemonProtection) {
- this.gcDaemonProtection = gcDaemonProtection;
- }
-
@Override
public void lifecycleEvent(LifecycleEvent event) {
// Initialise these classes when Tomcat starts
@@ -129,6 +129,41 @@ public class JreMemoryLeakPreventionList
}
/*
+ * Several components end up calling:
+ * sun.misc.GC.requestLatency(long)
+ *
+ * Those libraries / components known to trigger memory leaks due
to
+ * eventual calls to requestLatency(long) are:
+ * - javax.management.remote.rmi.RMIConnectorServer.start()
+ */
+ if (gcDaemonProtection) {
+ try {
+ Class<?> clazz = Class.forName("sun.misc.GC");
+ Method method = clazz.getDeclaredMethod("requestLatency",
+ new Class[] {long.class});
+ method.invoke(null, Long.valueOf(3600000));
+ } catch (ClassNotFoundException e) {
+ if (System.getProperty("java.vendor").startsWith("Sun")) {
+ log.error(sm.getString(
+ "jreLeakListener.gcDaemonFail"), e);
+ } else {
+ log.debug(sm.getString(
+ "jreLeakListener.gcDaemonFail"), e);
+ }
+ } catch (SecurityException e) {
+ log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);
+ } catch (NoSuchMethodException e) {
+ log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);
+ } catch (IllegalArgumentException e) {
+ log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);
+ } catch (IllegalAccessException e) {
+ log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);
+ } catch (InvocationTargetException e) {
+ log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);
+ }
+ }
+
+ /*
* Several components end up opening JarURLConnections without
first
* disabling caching. This effectively locks the file. Whilst more
* noticeable and harder to ignore on Windows, it affects all
@@ -170,41 +205,6 @@ public class JreMemoryLeakPreventionList
log.error(sm.getString("jreLeakListener.xmlParseFail"), e);
}
}
-
- /*
- * Several components end up calling:
- * sun.misc.GC.requestLatency(long)
- *
- * Those libraries / components known to trigger memory leaks due
to
- * eventual calls to requestLatency(long) are:
- * - javax.management.remote.rmi.RMIConnectorServer.start()
- */
- if (gcDaemonProtection) {
- try {
- Class<?> clazz = Class.forName("sun.misc.GC");
- Method method = clazz.getDeclaredMethod("requestLatency",
- new Class[] {long.class});
- method.invoke(null, Long.valueOf(3600000));
- } catch (ClassNotFoundException e) {
- if (System.getProperty("java.vendor").startsWith("Sun")) {
- log.error(sm.getString(
- "jreLeakListener.gcDaemonFail"), e);
- } else {
- log.debug(sm.getString(
- "jreLeakListener.gcDaemonFail"), e);
- }
- } catch (SecurityException e) {
- log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);
- } catch (NoSuchMethodException e) {
- log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);
- } catch (IllegalArgumentException e) {
- log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);
- } catch (IllegalAccessException e) {
- log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);
- } catch (InvocationTargetException e) {
- log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);
- }
- }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]