Uploaded image for project: 'iBatis for Java [READ ONLY]'
  1. iBatis for Java [READ ONLY]
  2. IBATIS-540

Classloader memory leak because of ThreadLocal in ResultObjectFactoryUtil

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.3, 2.3.4
    • Fix Version/s: 2.3.5
    • Component/s: Core
    • Labels:
      None

      Description

      I'm using iBatis in a webapp with Spring and facing memory leaks upon redeployment oft he webapp.
      I tracked the leaks to ibatis, where the class ResultObjectFactoryUtil has a static ThreadLocal factorySettings

      The problem is that the value bound to a Thread through this ThreadLocal is never nullified, and since the "factorySettings" is a static variable, the ThreadLocal instance is reachable as long as the ClassLoader of the webapp is reachable. But since the FactorySettings instance is bound to the Thread through a strong reference (see the JDK implementation of ThreadLocal in ThreadLocalMap$Entry), the classloader is finally never collected...

      The solution is to always cleanup the ThreadLocal after usage (in SqlExecurtor)
      I attach a patch for iBatis 2.3.4 to this issue

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jgbutler Jeff G. Butler
                Reporter:
                slaurent Sylvain Laurent
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: