https://issues.apache.org/bugzilla/show_bug.cgi?id=46957

           Summary: Memory leak: tags in JSPs don't release Page Context
           Product: Tomcat 6
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Jasper
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: martin.r...@centrum.cz


During investigation of memory leaks in our web-application I was checking heap
using jhat and I found that the biggest memory leak is caused by tomcat itself.
Heap contain big amount of instances of class PageContextImpl (over 1000).
These instances reference JspWriterImpl (property baseOut) which reference huge
buffer (property cb which in our case has 1MB size - in total these buffers use
over 1GB).
This situation happens during big load, my understanding (might be wrong) of
the situation is that pool containing Page Contexts is not big enough which
causes bigger number of page contexts being created and then released. But most
of them stay referenced by jsp classes via tag handlers so they can't be
garbage collected.

Partial fix could be done in method
org.apache.jasper.runtime.TagHandlerPool.reuse(Tag handler)
adding following code line at the begining of the method:
handler.setPageContext(null);

This fixes simple jsp like this:

<%...@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:if test="${true}">
   Test message
</c:if>

I've tested this patch and checked via jhat, reference is removed. But the
problem still remains for jsp with nested tags. My guess is that some fix
should be done in part generating servlet code from JSP to remove all
references to Page Context once the servlet finishes it's service method.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to