Mark (Eggers) and Mark (Thomas)

BLUF:  I might not have set up the necessary Log4J shutdown procedures.  Please 
(especially) see my responses flagged by ***.

-----Original Message-----
From: Mark Eggers [mailto:its_toas...@yahoo.com.INVALID] 
Sent: Thursday, July 21, 2016 8:32 PM
To: Tomcat Users List
Subject: Re: OutOfMemoryError: PermGen space

> Mark and Cris,
> 
> On 7/21/2016 12:47 PM, Mark Thomas wrote:
> > On 21/07/2016 18:17, Berneburg, Cris wrote:
> >> From: Mark Thomas [mailto:ma...@apache.org]
> > 
> > <snip/>
> > 
> >> 
> >> Used the Java Visual VM to pull a heap dump after the app restart and 
> >> GC.  Used Eclipse Memory Analyzer to analyze the heap dumps.
> >> Found the WebappClassLoader with started == false and used Path to GC 
> >> roots:
> >> 
> >> <classloader>
> >> org.apache.logging.log4j.core.jmx.LoggerContextAdminMBean ...
> >> com.sun.jmx.mbeanserver.StandardMBeanIntrospector
> >> 
> [SNIP]
> > 
> >> I don't see anything pointing back to our code.  With no previous 
> >> experience with heap analysis on my part, it looks to me to be due to 
> >> Log4J2.
> > 
> > Agreed.
> > 
> [SNIP]
> > 
> >> Not sure what else I can do.  Report it to the Log4J2 dev group 
> >> perhaps?
> > 
> > Ask on their users' list. It may be that when you use log4j2 in a 
> > webapp there is some clean-up method you need to call from a 
> > ServletContextListener.


OK, I'll follow up with that next-next.


> From the log4j2 web site:
> 
> https://logging.apache.org/log4j/2.x/manual/webapp.html


Thanks for pointing that out.  I'm looking through it again now:


> you'll need to add the log4j-web module to your deployment [...]
>
> To avoid problems the Log4j shutdown hook will automatically be
> disabled when the log4j-web jar is included. 


Hmm...  Log4j-web-2.3.jar is included in our apps lib folder.  I wonder if 
there is a shutdown procedure I am missing then.


> If you are using Log4j in a Servlet 2.5 web application, or if
> you have disabled auto-initialization with the
> isLog4jAutoInitializationDisabled context parameter, you must
> configure the Log4jServletContextListener and Log4jServletFilter
> in the deployment descriptor or programmatically.


*** I did not do that at all.  Is it the context listener's responsibility for 
shutting down properly?  Why the filter is needed?  Guess I'll set them up and 
see if that makes a diff.


> Asynchronous Requests and Threads
> [SNIP]
> Note that you must call clearLoggerContext once your thread is
> finished processing. Failing to do so will result in memory leaks.


*** Wait a minute.  Maybe I don't understand how servlet threads work in 
Tomcat.  We don't launch any separate threads, but do override doPost and doGet 
in our servlets.  Is that synchronous or asynchronous?  Do we still have to 
call webLifeCycle.clearLoggerContext?


> In servlet spec 3.0 and greater, there appears to be annotation
> that gets everything running.
> 
> In servlet spec 2.5, you'll have to add a bunch of stuff to
> your web.xml.
>
> The reference above gives a more detailed explanation and an
> example for the 2.5 web.xml.


Since we still use Tomcat 6, we used a 2.5 servlet spec config.  All the Log4J 
config info is in log4j2.xml.


> I am just starting to get things migrated to log4j2,
> so I'll know how it goes shortly.


Please do!

--
Cris Berneburg
CACI Lead Software Engineer


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

Reply via email to