Bug 31510 - Memory leaks due to JspWriterImpl keeping reference to ServletResponse after recycle()
Summary: Memory leaks due to JspWriterImpl keeping reference to ServletResponse after ...
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 5.0.28
Hardware: All All
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2004-10-02 14:12 UTC by Alexei Yudichev
Modified: 2004-11-16 19:05 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Alexei Yudichev 2004-10-02 14:12:48 UTC
This problem causes severe memory leaks in JBoss app server with Jetty servlet 
container installed (that is using Jasper). I tested it with JBoss 3.2.6RC1 and 
Jetty 5.0.0. Please see related bug reports: https://sourceforge.net/tracker/?
func=detail&aid=973162&group_id=22866&atid=376685 and 
func=detail&aid=1038066&group_id=7322&atid=107322. In short, after JBoss web 
application context is destroyed, there is still a hard reference chain (see 
UnifiedClassLoader3.html) from Jasper's pool of JspContexts to JBoss' 
UnifiedClassLoader3. The most logical place to break the chain is, in my 
opinion, to set org.apache.jasper.runtime.JspWriterImpl.response field to null 
inside JspWriterImpl.recycle() method. It looks safe, because JspWriterImpl is 
always initialized with a new response object before use. And it looks logical, 
because why should a recycled JspWriter keep reference to a response which it 
will never make use of, being recycled. In my test instalation, adding 

response = null;

to JspWriterImpl.recycle() resolves the problem.
Comment 1 Yoav Shapira 2004-10-05 14:52:09 UTC
Fixed in Tomcat 5.0 branch, will fix in 5.5 branch after my 11am meeting.  
Thanks for tracking and reporting this.
Comment 2 Yoav Shapira 2004-10-05 16:09:25 UTC