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

'Memory Leak' in Transformer logic

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Resolution: Fixed
    • 2.2.0
    • None
    • None
    • Operating System: Windows NT/2K
      Platform: PC
    • 6075

    Description

      The Problem
      ------------
      The "Templates" object maintains a pool of Iterators in order to improve
      performance – rather than create new Iterators during the XSL transformation,
      it reuses Iterators from the pool. Unfortunately, there is am indirect
      reference from the "free" Iterator to the "Transformer" object that last used
      it. That means that the "Transformer" object is still referenced, and it is not
      freed by the garbage collector when we are done with it. It is not freed until
      the next time the same page is displayed. At that time, the Iterator is reused
      and the stale reference is clear. Unfortunately, we now have a reference to the
      new "Transformer" object.

      The overall effect is that we have at least one lingering "Transformer" object
      for each "Templates". Each "Transformer" object (and its children) can
      sometimes add up to 2Mb of heap memory.

      The Fix
      -------
      Alter the code to destroy Iterators rather than add them to the free pool.

      org/apache/xpath/axes/IteratorPool.java

      /**

      • Add an instance of the given object to the pool
        *
        *
      • @param obj Object to add.
        */
        public synchronized void freeInstance(DTMIterator obj) { // -------------------------------------------- // Destroy Iterator rather than add to pool // m_freeStack.addElement(obj); // -------------------------------------------- }

      The Result
      ----------
      No noticable problems with perform
      All TransformImpl objects are cleared in the next call to system.gc()

      I used "JPROBE" to track lingering objects.

      Attachments

        1. ASF.LICENSE.NOT.GRANTED--leak.xsl
          0.3 kB
          Morris Kwan
        2. ASF.LICENSE.NOT.GRANTED--leak.patch
          5 kB
          Morris Kwan
        3. ASF.LICENSE.NOT.GRANTED--bug-6075-attachment-1.txt
          1 kB
          mick woolley

        Activity

          People

            sboag@apache.org Scott Boag
            dave.edmunds@cognos.com Dave Edmunds
            Votes:
            4 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: