DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6075>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6075

"Memory Leak" in Transformer logic

           Summary: "Memory Leak" in Transformer logic
           Product: XalanJ2
           Version: 2.2.0
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: org.apache.xalan.transformer
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


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.

Reply via email to