You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@logging.apache.org by "Ralph Goers (JIRA)" <ji...@apache.org> on 2017/06/08 06:57:18 UTC
[jira] [Commented] (LOG4J2-1727) Calling static method during
re-/undeploy causes memory leak in Tomcat
[ https://issues.apache.org/jira/browse/LOG4J2-1727?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16042302#comment-16042302 ]
Ralph Goers commented on LOG4J2-1727:
-------------------------------------
Log4j documents that it must be shutdown last for this exact reason.
> Calling static method during re-/undeploy causes memory leak in Tomcat
> ----------------------------------------------------------------------
>
> Key: LOG4J2-1727
> URL: https://issues.apache.org/jira/browse/LOG4J2-1727
> Project: Log4j 2
> Issue Type: Bug
> Affects Versions: 2.7
> Reporter: Robin Jansohn
>
> Pretty similar issue to LOG4J2-1419 I guess, but this is not caused by another context AFAICS.
> Reproducer webapp: https://github.com/jansohn/log4j2-threadlocal/tree/log4j2-leaks
> If I call a static method in a class which contains a Logger instance from the {{contextDestroyed()}} method the LoggerContext gets re-initialized as the original LoggerContext has already been destroyed (caused by the too early log4j context shutdown, LOG4J2-658 / LOG4J2-1098).
> A workaround would be to call a non-static method from an already initialized object but I don't think this is feasible as a permanent solution.
> {code:java}
> @Override
> public void contextDestroyed(ServletContextEvent sce) {
> log.info("Servlet context is being destroyed!");
> ShutdownHelper.closeConnectionPools();
> //helper.closeDatabaseConnectionPools();
> }
> {code}
> {noformat}
> Dez 08, 2016 2:45:28 PM org.apache.catalina.core.StandardContext reload
> INFORMATION: Reloading Context with name [/log4j2webapp] has started
> Dez 08, 2016 2:45:28 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
> WARNUNG: The web application [log4j2webapp] appears to have started a thread named [Log4j2-TF-6-Scheduled-2] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
> sun.misc.Unsafe.park(Native Method)
> java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
> java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
> java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
> java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> java.lang.Thread.run(Thread.java:745)
> Dez 08, 2016 2:45:28 PM org.apache.jasper.servlet.TldScanner scanJars
> INFORMATION: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
> 2016-12-08 14:45:29,335 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] com.test.webapp.MyWebapp - Servlet context is being initialized!
> Dez 08, 2016 2:45:29 PM org.apache.catalina.core.StandardContext reload
> INFORMATION: Reloading Context with name [/log4j2webapp] is completed
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)