Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Blocker Blocker
    • Resolution: Unresolved
    • Affects Version/s: 2.7
    • Fix Version/s: None
    • Component/s: Xalan
    • Labels:
      None

      Description

      In class org.apache.xml.utils.XMLReaderManager

      getXMLReader() method creates a new XMLReader (i.e. SAXParser) and stores it into ThreadLocal.

      releaseXMLReader() does not remove (set to null) ThreadLocal thus creating a permanent leak.

      Unfortunately the size of the cached Reader is typically dependent upon the size of the XML document you process (depends on implementation but this is the case with xerces SAXParser). In heavy load server environments with thread pools of tens and hundreds of threads the server sustains a significant memory leak (hundreds of megabytes - depending on the XML document sizes and number of threads in a thread pools).

      A fix is trivial:

      Put the following line at the end of releaseXMLReader method:

      m_readers.set(null);

      I wonder, why is reader stored in ThreadLocal in the first place?

      1. xalan-j2-2.6.0-xmlmemoryleak-tm2l.patch
        0.8 kB
        Michel Loiseleur
      2. retained-object-sizes.jpg
        54 kB
        Eric Burke
      3. gc-roots.jpg
        34 kB
        Eric Burke

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Marko Strukelj
          • Votes:
            10 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:

              Development