You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2002/08/22 21:42:35 UTC

DO NOT REPLY [Bug 11947] New: - Memory leak of CaptureLog objects

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=11947>.
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=11947

Memory leak of CaptureLog objects

           Summary: Memory leak of CaptureLog objects
           Product: Tomcat 4
           Version: 4.1.5
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Catalina
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: billb@haht.com


A memory profiler that I am using reports a growing number of CaptureLog 
objects that are referenced in the static Hashtable "logs" in the class 
org.apache.tomcat.util.log.SystemLogHandler.   By examing the Tomcat source 
code, I believe I have discovered the reason for this (but not the appropriate 
fix):  

1. The class org.apache.catalina.connector.RequestBase calls 
SystemLogHandler.startCapture() in the setContext() method, and calls 
SystemLogHandler.stopCapture() in the recycle() method.   So if setContext() is 
called and recycle() isn't, stopCapture is not called, and the CaptureLog 
object created by startCapture isn't removed from the Hashtable in 
SystemLogHandler.

2. In org.apache.catalina.core.ApplicationContext, the getRequestDispatcher() 
method calls setContext() on a HttpRequestBase object, but doesn't call recycle
():

        // The remaining code is duplicated in PrivilegedGetRequestDispatcher,
        // we need to make sure they stay in sync
        HttpRequestBase request = new HttpRequestBase();
        request.setContext(context);
        request.setContextPath(context.getPath());
        request.setRequestURI(contextPath + relativeURI);
        request.setQueryString(queryString);
        Wrapper wrapper = (Wrapper) context.map(request, true);
        if (wrapper == null)
            return (null);

        // Construct a RequestDispatcher to process this request
        HttpServletRequest hrequest =
            (HttpServletRequest) request.getRequest();
		
        return (RequestDispatcher) new ApplicationDispatcher(wrapper,
                        hrequest.getServletPath(),
                        hrequest.getPathInfo(),
                        hrequest.getQueryString(),
                        null);

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>