Uploaded image for project: 'HiveMind'
  1. HiveMind
  2. HIVEMIND-161

ThreadLocal object is never removed in ThreadEventNotifierImpl and holds the classloader

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 1.1
    • 1.1.1
    • framework
    • None
    • Tomcat 5.5.12, J2SE 1.6 Mustang build 62, Win XP SP2

    Description

      The following prevents the web application classloader from being garbage collected on hot redeploys of web applications.

      Please note that the issue is present on J2SE 1.5 as well. I use 1.6 only because it has far better support for JVMTI and as such the issue was easy to discover with YourKit profiler. Here it is:

      1. org.apache.hivemind.service.impl.ThreadEventNotifierImpl puts EventListenerList ("list" variable) on its private ThreadLocal "_storage" variable in addThreadCleanupListener method.

      2. No where in that class does the actual list gets removed from ThreadLocal.

      Thus, the WebappClassLoader cannot be garbage collected because one of the object that it loaded (i.e. EventListenerList) is strongly referenced by live threads in the container, which leads to huge memory leaks on hot-redeploys.

      Attachments

        1. hivemind-threadlocals.pdf
          6 kB
          Kyrill Alyoshin

        Activity

          People

            hlship Howard Lewis Ship
            kyrill007 Kyrill Alyoshin
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: