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

> 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.
> 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:

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">

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