DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=31914>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=31914 Memory leak when using Jsp tags (JspWriter) Summary: Memory leak when using Jsp tags (JspWriter) Product: Tomcat 5 Version: 5.0.28 Platform: All OS/Version: All Status: NEW Severity: Major Priority: Other Component: Jasper AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] Hi, we find out that there is a memory leak in Tomcat 4.1.31 and Tomcat 5.0.28 when using the JspWriter in inner JSP-TAGS. We create a very small jsp (and an easy jsp-tag) which we place in a test webapp and start it using the following command: "http://127.0.0.1:8080/test/memtest?i=<number>". We this example application we got the following results (Used/Total memory in MB): Tomcat 4.1.31 ============= Number Used Total ResponseTime 10.000 5.045 15.802 3 Sec 20.000 5.500 15.802 5 Sec 30.000 5.962 15.802 45 Sec 40.000 5.962 15.802 120 Sec 80.000 no response in 6 Minutes !!! 40.001 8.262 15.802 1 Sec 20.001 8.266 15.802 1 Sec Tomcat 5.0.28 ============= Number Used Total ResponseTime 10.000 4.900 14.344 1 Sec 20.000 5.900 14.344 1 Sec 30.000 6.400 14.344 1 Sec 40.000 6.600 14.344 2 Sec 80.000 8.491 15.200 2 Sec 40.001 8.491 15.200 1 Sec 20.001 8.491 15.200 1 Sec Conclusion: ========== Tomcat 5.0.28 is much faster and stabil for this testcase. Tomcat 4.1.31 becomes fast after the big memory is allocated. Both versions did not release the memory. The above data results can be reproduced. The memory problem occurs only if we create large amount of data in an inner tag. User JSP: <%@ page errorPage="/util/errorpge.jsp" import="java.beans.*, java.lang.reflect.*, java.util.*, java.sql.*, java.lang.*, java.text.*, java.io.* " %> <%@ taglib uri="http://www.test.de/jsp/" prefix="dbs"%> <% // response.setDateHeader("Expires", 0); String amount = request.getParameter("i"); int ii = new Integer(amount).intValue(); %> <html> <p>BEFORE <p> <dbs:SelectMemTest> <p>inner before <%=amount%> <% for (int i = 0; i < ii; i++) { out.println("<br><p>"+i+" and next"); } %> <p>inner after </dbs:SelectMemTest> <p>after<p> <% Runtime runtime = Runtime.getRuntime(); DecimalFormat df = new DecimalFormat( "###,###,###,000,000" ); %> <%= "<p>Total Memory " + df.format(runtime.totalMemory()) %> <%= "<p>Free Memory " + df.format(runtime.freeMemory()) %> <%= "<p>Max Memory " + df.format(runtime.maxMemory()) %> <% runtime.gc(); session.invalidate(); %> <%= "<p>after gc and session invalidate:<p>Total Memory " + df.format (runtime.totalMemory()) %> <%= "<p>Free Memory " + df.format(runtime.freeMemory()) %> <%= "<p>Used Memory " + df.format(runtime.totalMemory() - runtime.freeMemory()) %> Used Tag-Source: package com.dbsmart.taglib; import java.io.IOException; //import java.io.PrintWriter; import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.tagext.BodyTagSupport; /** * */ public class SelectMemTest extends BodyTagSupport { /* * Standard constructor is required. */ public SelectMemTest() { super(); } public int doStartTag() throws JspException { return EVAL_PAGE; } public int doEndTag() throws JspException { String value = bodyContent.getString(); bodyContent.clearBody(); try { //PrintWriter out = pageContext.getResponse().getWriter(); JspWriter out = pageContext.getOut(); out.write(value); } catch (IOException e) { throw new JspException("IOException occured: " + e); } release(); return EVAL_PAGE; } public void release() { super.release(); } } The taglib pooling was set to false. What else can we do to reduce the memory. I can send the very small complete webapp to You, if some is interessested. Currently we are running Tomcat 4 in Produktion, after migrating our tag from Tomcat 3. In Tomcat 3 we did not have this problem. Thank You for Your help. Klaus Pröll --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
