Around 9/6/16 Chris Schultz replied to the "WAR isolation lifecycle" thread 
with:

> There are some libraries that don't shut down well, or the applications
> that use them don't properly shut them down. The solution is to either
> fix the library (ask them!), or use Tomcat's "leak prevention listener"
> to pre-load those classes that represent a problem.
>
> http://tomcat.apache.org/tomcat-8.0-doc/config/listeners.html#JRE_Memory_Leak_Prevention_Listener_-_org.apache.catalina.core.JreMemoryLeakPreventionListener
>
> You want to read about the "classesToInitialize" attribute.

Having recently dealt with some memory leaks, I was curious and read through.  
Great!  This might help in future struggles.  However, being still somewhat new 
to this, I was unable to determine how to invoke the classesToInitialize 
parameter inside the server.xml from the documentation page.  Googling around 
led to this:

http://stackoverflow.com/questions/11872316/tomcat-guice-jdbc-memory-leak#19027873

The critical part is:

> In tomcat/conf/server.xml, modify (inside the Server element):
> <Listener 
> className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
>
> to
>
> <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"
>          classesToInitialize="com.mysql.jdbc.NonRegisteringDriver" />

Aha, that's the XML syntax!  Why didn't I know that?

So, could we add a small example server.xml snippet to the 
JreMemoryLeakPreventionListener documentation to make it clear to newbies how 
to add the classesToInitialize option?  Something like:

<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"
      classesToInitialize="oracle.jdbc.driver.OracleTimeoutThreadPerVM" />

Is this also valid?

<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener">
      
<classesToInitialize>oracle.jdbc.driver.OracleTimeoutThreadPerVM</classesToInitialize>
</Listener>

Would examples look better after the Attribute/Description table as a separate 
section or embedded directly within the table?

--
Cris Berneburg
Lead Software Engineer, CACI

Reply via email to