Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1159

ThreadLocal leaks in Tomcat8 (even if Async Loggers are not used)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4, 2.4.1
    • 2.5
    • Core
    • None

    Description

      Since v2.4 there a TreadLocal warnings reported by Tomcat. This happens even when the application is not configured to use Async Loggers.

      A minimal webapp to reproduce can be found here: https://github.com/jansohn/log4j2-threadlocal

      WARNUNG: The web application [log4j2webapp] appears to have started a thread named [AsyncLogger-1] 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.park(LockSupport.java:175)
       java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
       com.lmax.disruptor.BlockingWaitStrategy.waitFor(BlockingWaitStrategy.java:45)
       com.lmax.disruptor.ProcessingSequenceBarrier.waitFor(ProcessingSequenceBarrier.java:55)
       com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:123)
       java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
       java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
       java.lang.Thread.run(Thread.java:745)
      Okt 14, 2015 1:06:48 PM org.apache.catalina.loader.WebappClassLoaderBase checkThreadLocalMapForLeaks
      SCHWERWIEGEND: The web application [log4j2webapp] created a ThreadLocal with key of type [org.apache.logging.log4j.core.async.AsyncLogger$Info$1] (value [org.apache.logging.log4j.core.async.AsyncLogger$Info$1@1d29f54]) and a value of type [org.apache.logging.log4j.core.async.AsyncLogger.Info] (value [org.apache.logging.log4j.core.async.AsyncLogger$Info@1ea59ba]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
      

      Attachments

        Issue Links

          Activity

            People

              rpopma Remko Popma
              jansohn Robin Jansohn
              Votes:
              3 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: