Uploaded image for project: 'XalanJ2'
  1. XalanJ2
  2. XALANJ-2600

Memory leak in TransformerIdentityImpl

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.7.2
    • Fix Version/s: 2.7.3
    • Component/s: Xalan
    • Security Level: No security risk; visible to anyone (Ordinary problems in Xalan projects. Anybody can view the issue.)
    • Labels:
      None
    • Xalan info:
      PatchAvailable
    • Flags:
      Patch

      Description

      Hi.

      I found a serious memory leak in the Xalan library. It is caused by the org.apache.xalan.transformer.TransformerIdentityImpl class.

      I try to explain mechanism how the memory leak is caused:

      Web application is deployed on SAP NetWeaver AS with Java 1.6 (1.6.0_95). The application uses Spring WS library but also another libraries with dependency to Xalan library.

      When the web service is invoked, then the TransformerIdentityImpl class is used. This class is used because it's extends javax.xml.transform.Transformer and it is created by Java core method - javax.xml.transform.TransformerFactory.newInstance().

      A class com.sun.xml.internal.messaging.saaj.soap.EnvelopeFactory is used for handling web services. This object also contains cache (ParserPool) with SAXParser objects (com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl). As key for this cache is used an application class loader.

      EnvelopeFactory object and SAXParserImpl objects are loaded by a system class loader, but TransformerIdentityImpl class is loaded by an application class loader.

      During handling of web service a method org.apache.xalan.transformer.TransformerIdentityImpl.transform(Source, Result) is invoked. This method uses SAXParser as a reader. Problem is that this method register self for handling properties (eg: "http://xml.org/sax/handlers/DeclHandler") but after processing method doesn't unregister self from SAXParser. It means that objects loaded by the system class loaded has dependencies on objects loaded by the application class loader.

      Objects are still loaded after application is undeployed because cached SAXParser references TransformerIdentityImpl.

      I prepared very simple patch to fix this problem. In the attachment is also picture which demonstrates situation.

        Attachments

        1. TransformerIdentityImpl.java.patch
          4 kB
          Samuel Brezáni
        2. xalan_memory_leak.jpg
          67 kB
          Samuel Brezáni

          Activity

            People

            • Assignee:
              garydgregory Gary Gregory
              Reporter:
              samuel.brezani@gmail.com Samuel Brezáni
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: