You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Berneburg, Cris J. - US" <cb...@caci.com> on 2016/09/20 16:06:34 UTC

JreMemoryLeakPreventionListener docs example

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


RE: JreMemoryLeakPreventionListener docs example

Posted by "Berneburg, Cris J. - US" <cb...@caci.com>.
Chris

-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net] 
Sent: Saturday, September 24, 2016 11:55 AM
To: Tomcat Users List
Subject: Re: JreMemoryLeakPreventionListener docs example

[SNIP]

>>>> 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?
[SNIP]
>> Sure, how do I get started?

> Use a subversion client to check out a copy of this URL:
>
> https://svn.apache.org/repos/asf/tomcat/trunk
>
> Then, edit webapps/docs/config/listeners.xml and look for
> JreMemoryLeakPreventionListener.  That file is a mix of HTML
> and XML that gets transformed into HTML by an XSLT as part
> of the build process.
>
> You can test your edits by running "ant build-docs" and then
> viewing the generated .html files in your web browser.
>
> Once you are happy with your edits, do this:
>
> svn diff > my-great-patch.diff
>
> ... and attach it to a Bugzilla ticket describing what you are
> trying to do (e.g. "Improve documentation for
> JreMemoryLeakPreventionListener") .

Thanks for the instructions.  Wow.  OK, will do.

>> Yay, I'm going to be *famous*!  :-D
>
> It's a slippery slope, my friend. After this, I'll be pressuring
> you for trivial code patches :)

Code?  What is this "code" of which you speak?  ;-)

--
Cris Berneburg, 
CACI Lead Software Engineer


RE: JreMemoryLeakPreventionListener docs example

Posted by "Berneburg, Cris J. - US" <cb...@caci.com>.
Chris and Mark

-----Original Message-----
From: Mark Thomas [mailto:markt@apache.org] 
Sent: Wednesday, September 28, 2016 2:21 PM
To: Tomcat Users List
Subject: Re: JreMemoryLeakPreventionListener docs example

[SNIP]

>>> attach it to a Bugzilla ticket describing what you are
>>> trying to do (e.g. "Improve documentation for
>>> JreMemoryLeakPreventionListener") .
>> 
>> What Tomcat product should I use when creating the bug?
>> There are multiple versions to choose from, but I checked
>> out code from the trunk, not a specific branch.
>
> Tomcat 9 please.

Done.  Bug #60188, "Improve documentation for JreMemoryLeakPreventionListener" submitted with attachment "Chris_Schultz_is_Awesome.diff" as the patch.  ;-)

--
Cris Berneburg
CACI Lead Software Engineer


RE: JreMemoryLeakPreventionListener docs example

Posted by "Berneburg, Cris J. - US" <cb...@caci.com>.
-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net] 
Sent: Wednesday, September 28, 2016 4:43 PM
To: Tomcat Users List
Subject: Re: JreMemoryLeakPreventionListener docs example

>>>> It's a slippery slope, my friend. After this, I'll be
>>>> pressuring you for trivial code patches :)
>>>
>>> Gah, you tricked me into downloading the whole Tomcat
>>> source code!  The slippery slope slide has already
>>> started!  :-)
>> 
>> Excellent.
>
> I really hope you were tenting your fingers[1] when you
> said that.
>
> - -chris
>
> [1] https://thestranded.files.wordpress.com/2014/02/burns-excellent.gif

In my imagination he pronounced it, "Exxxxcellent".

--
Cris Berneburg
CACI Lead Software Engineer


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


Re: JreMemoryLeakPreventionListener docs example

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Mark,

On 9/28/16 2:21 PM, Mark Thomas wrote:
> On 28/09/2016 15:07, Berneburg, Cris J. - US wrote:
>> Chris
>> 
>> -----Original Message----- From: Christopher Schultz
>> [mailto:chris@christopherschultz.net] Sent: Saturday, September
>> 24, 2016 11:55 AM To: Tomcat Users List Subject: Re:
>> JreMemoryLeakPreventionListener docs example
>> 
>>> Once you are happy with your edits, do this:
>> 
>> While I can't say that "happy" is the right word, I will say
>> "done".
>> 
>>> ... and attach it to a Bugzilla ticket describing what you are
>>> trying to do (e.g. "Improve documentation for
>>> JreMemoryLeakPreventionListener") .
>> 
>> What Tomcat product should I use when creating the bug?  There
>> are multiple versions to choose from, but I checked out code from
>> the trunk, not a specific branch.
> 
> Tomcat 9 please.
> 
>>> Use a subversion client to check out a copy of this URL:
>>> 
>>> https://svn.apache.org/repos/asf/tomcat/trunk
>> [SNIP]
>>> It's a slippery slope, my friend. After this, I'll be
>>> pressuring you for trivial code patches :)
>> 
>> Gah, you tricked me into downloading the whole Tomcat source
>> code!  The slippery slope slide has already started!  :-)
> 
> Excellent.

I really hope you were tenting your fingers[1] when you said that.

- -chris

[1] https://thestranded.files.wordpress.com/2014/02/burns-excellent.gif
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJX7Cs3AAoJEBzwKT+lPKRYWF0P/007VTKJyKKNgFhFCZXOSaTg
lR/cF0X3LlAXDwRa9R97zkaDMYA47Rafd+mjen+SByP4+DQoOhB54vUm+BMH87Lo
g7GLEttItZHNdQKcJx3vdrR6L8Mg0ZeKNt4iHlSvTbt8c6g0ZncDEuwin2nSSZ3w
reLog7BXbbm2ZiCddSxXrj9QQ+o5hRPD4OxIYpSny8wKv5B67JjG4SX9jXqc5Pt0
/TqQS6EMl2l+RfC8PoWDgOKIxwtMWho4TozkgQ0zs66eV5xL0Yvq7mKhElF3ukc2
k73+Wd4MHJSqyVXUyJ5stG9/Jpqly0jGCr0UHoIjiCrQ8O4qXMb79vcYTHT6IuZ4
8u+RT6bGb69yxyWK745ofoXdlMJEIbbjIIXIldzurKtjKRQ5G9Qm7cO71aLGYq5N
rnRODCOg4ns1+F3jFEqX/T6mB4PpQV8yqxSPFrCwIGQj2i7LU4Kqu2+Jiw6jZbi3
FGxwAFKbEFgEJGWzP/HG6mpMB+SelwANx1pj7HITEGeIFZLWmqZc0TI0PBHkRp9d
elhrj0vPcA5U8oxkFB0Z1bu7ASxHaxUJsCOK7Mnj4A0ZOShHmnjI8+FnfwDRTbw6
i0oFQksuoAyC7Nk2n/vkiCDn9GXUnBfDt+8jdjNThlYgSPurcuMHS9JBGQdYHq/Q
y4RfkjOaWOgn0o83ozPv
=LC8A
-----END PGP SIGNATURE-----

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


Re: JreMemoryLeakPreventionListener docs example

Posted by Mark Thomas <ma...@apache.org>.
On 28/09/2016 15:07, Berneburg, Cris J. - US wrote:
> Chris
> 
> -----Original Message-----
> From: Christopher Schultz [mailto:chris@christopherschultz.net] 
> Sent: Saturday, September 24, 2016 11:55 AM
> To: Tomcat Users List
> Subject: Re: JreMemoryLeakPreventionListener docs example
> 
>> Once you are happy with your edits, do this:
> 
> While I can't say that "happy" is the right word, I will say "done".
> 
>> ... and attach it to a Bugzilla ticket describing what you are trying
>> to do (e.g. "Improve documentation for JreMemoryLeakPreventionListener") .
> 
> What Tomcat product should I use when creating the bug?  There are multiple versions to choose from, but I checked out code from the trunk, not a specific branch.

Tomcat 9 please.

>> Use a subversion client to check out a copy of this URL:
>>
>> https://svn.apache.org/repos/asf/tomcat/trunk
> [SNIP]
>> It's a slippery slope, my friend. After this, I'll be pressuring you
>> for trivial code patches :)
> 
> Gah, you tricked me into downloading the whole Tomcat source code!  The slippery slope slide has already started!  :-)

Excellent.

Mark


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


RE: JreMemoryLeakPreventionListener docs example

Posted by "Berneburg, Cris J. - US" <cb...@caci.com>.
Chris

-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net] 
Sent: Saturday, September 24, 2016 11:55 AM
To: Tomcat Users List
Subject: Re: JreMemoryLeakPreventionListener docs example

> Once you are happy with your edits, do this:

While I can't say that "happy" is the right word, I will say "done".

> ... and attach it to a Bugzilla ticket describing what you are trying
> to do (e.g. "Improve documentation for JreMemoryLeakPreventionListener") .

What Tomcat product should I use when creating the bug?  There are multiple versions to choose from, but I checked out code from the trunk, not a specific branch.

> Use a subversion client to check out a copy of this URL:
>
> https://svn.apache.org/repos/asf/tomcat/trunk
[SNIP]
> It's a slippery slope, my friend. After this, I'll be pressuring you
> for trivial code patches :)

Gah, you tricked me into downloading the whole Tomcat source code!  The slippery slope slide has already started!  :-)

--
Cris Berneburg
CACI Lead Software Engineer


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


Re: JreMemoryLeakPreventionListener docs example

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Cris,

On 9/22/16 1:35 PM, Berneburg, Cris J. - US wrote:
> Chris
> 
>>> 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"
>>> />
>> 
>> Care to make a formal documentation patch? You'll get your name
>> in the changelog :)
> 
> Sure, how do I get started?

Use a subversion client to check out a copy of this URL:

https://svn.apache.org/repos/asf/tomcat/trunk

Then, edit webapps/docs/config/listeners.xml and look for
JreMemoryLeakPreventionListener. That file is a mix of HTML and XML
that gets transformed into HTML by an XSLT as part of the build process.

You can test your edits by running "ant build-docs" and then viewing
the generated .html files in your web browser.

Once you are happy with your edits, do this:

svn diff > my-great-patch.diff

... and attach it to a Bugzilla ticket describing what you are trying
to do (e.g. "Improve documentation for JreMemoryLeakPreventionListener")
.

> Yay, I'm going to be *famous*!  :-D

It's a slippery slope, my friend. After this, I'll be pressuring you
for trivial code patches :)

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJX5qHZAAoJEBzwKT+lPKRYHskP/2dDC78IpCpSPxalaXoGpGzv
HoEfX8dTGyNgDgY/F35jN2VfcAudhGMYEL189+s9Gc7hsBhLk1H9Mxy6MOpHqAPP
Ww+UuqZq8PXGOldgKI9Y13PiCxhE3bhLRYj47QzN2cCiZS3bFjUDnEtH/8xbdoXd
lLHdozLhaa9MS2uk6ez77DQUfdw/daxZMxOw0AxvSaQn9tOCXEQm/hO1tAnePHKO
vGfmATeYLU1jILtT/VSLqHLIj1s4d4gqGJiVcFKU5k6jDZoRVXhiJBGNYESRCgKQ
1hHKaS+puuLytyW/c9MVxf+8ZA3qtScNK/TRGFddzeTyCNjfmSdJDBhLXgr/WvoO
B7BukMXeJu3dgN3FKKGHQj2GhHiBIwuo8mLz+hp3hGASzk/07UajnxzsyS1Ewuf2
W9vUwVSSaPK+uGRiVgzojpaGTh4uzvwPgilBtj2EKav5nI3DJBJxwE09kgeszLpk
5dLGIwp8HnZwI/zDyDMKjSx30ikXo/3h2zvALRnSZYQ2jkLRSVDUeyHWO5ZLYQr5
zjvr5DKOLxyT9AVkUN+z4g5NWaT7x1PGCP4lmZG42rCEmC95tef1wLLrF1Y6mqI+
OG1YqzyTEsTiNnhws0eE3ihDlTd5Tz9DtjnNVWecl8KpeWoLghZXIYzoQ5l4EqHZ
LK69dD/puiEhlRLuakDS
=Bjo1
-----END PGP SIGNATURE-----

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


RE: JreMemoryLeakPreventionListener docs example

Posted by "Berneburg, Cris J. - US" <cb...@caci.com>.
Chris

>> 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" />
>
> Care to make a formal documentation patch? You'll get your name in the changelog :)

Sure, how do I get started?  Yay, I'm going to be *famous*!  :-D


>> Is this also valid?
>> 
>> <Listener
>> className="org.apache.catalina.core.JreMemoryLeakPreventionListener">
>>
>> <classesToInitialize>oracle.jdbc.driver.OracleTimeoutThreadPerVM
>> </classesToInitialize>
>> </Listener>
>
> I'm not sure but I don't think so. It all depends upon how Tomcat
> has configured the digester, since it treats child elements and
> element attributes differently.

OK, won't include that syntax.


>> Would examples look better after the Attribute/
>> Description table as a separate section or embedded
>> directly within the table?
>
> Definitely outside of the table IMO.

OK, will place examples section outside after the table.

--
Cris Berneburg
CACI Lead Software Engineer


Re: JreMemoryLeakPreventionListener docs example

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Cris,

On 9/20/16 12:06 PM, Berneburg, Cris J. - US wrote:
> 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_Mem
ory_Leak_Prevention_Listener_-_org.apache.catalina.core.JreMemoryLeakPre
ventionListener
>>
>>
>> 
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-l
eak#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" />

Care to make a formal documentation patch? You'll get your name in the
changelog :)

> Is this also valid?
> 
> <Listener
> className="org.apache.catalina.core.JreMemoryLeakPreventionListener">
>
> 
<classesToInitialize>oracle.jdbc.driver.OracleTimeoutThreadPerVM</classe
sToInitialize>
> </Listener>

I'm not sure but I don't think so. It all depends upon how Tomcat has
configured the digester, since it treats child elements and element
attributes differently.

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

Definitely outside of the table IMO.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJX4YDLAAoJEBzwKT+lPKRYU2EQAJK9n62A3aDELeDU8ORMJCKy
GiaUtIOz+aGgf2dzBLFaMGG07mgNr+qhIHHt0/XU0MYnlAL5++bEGuJ+E+gjiLNs
LIOXD3W0C5ocsTNV7bl0GRxbHHqioyWo5x33LMa83R5FCIxfIfEpCCKtJ+xEoymi
ZzFBuZL3Cb7mSFfZrs0VzfOhemlA4UkK2cWxXoOd/nzIdsUOJnurcM8OZbP3BK28
HHTTwCAlVzcuFb/Tt88+o69KrLtwzPAOaRerGcebxs8E1sgAw05Amc7iLryXQUpn
IJGpGOdtHfZ8btbNTfuCPCdfeqQ8rjD7Fh+2jNAoJe1L+1dvk1pqMuuJq1h4rT34
m2WbgcJhaQKm5NPD94j/12pmZLgz/pP+uYgXoBLNCyNKI2mCK1kMYevAweMIneCa
JwD0p+MPqd2QXRmyihzJIaBNTeM2Jjp/HQH7qHxW7SkBBfskK50memFH89JsgUs7
/WjHIs1KvfvV+iigFsr8cqx/qHKRKxcgP3XnaQ4Hqu8CidiwD/1IMhpRGHSDDrkY
hMCs8dtK15dCQ6YkuCHBFLTMJjpowiBjbJYKHUxx6zcLr5q3utQx1hy/nxiES6eA
CeLPeUb/zVpuIsSwcNyZ4HOR+z1ymxmvlkNaNZBkWc1kW/6IKxkg4ptFqmyNTYG5
/Av7DhIUoGO4nGrTvmAv
=aXo7
-----END PGP SIGNATURE-----

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