You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "Seiler, Christian" <c....@cassiopeia.com> on 2002/03/07 19:33:38 UTC

AW: memory leak?

Hi,
I'm using Tomcat 3.2.4 (Redhat7.2, Blackdown 1.3.1_02) and encountered
exactly the same problem.
After some hours of normal operations the VM suddenly allocates huge amounts
of memory.

To track the object allocation I turned on the memory profiling option
-Xrunhprof:heap=sites
(the JVM is damn slow, so this is not apropriate for production).

Here we go:

rank   self  accum    bytes objs   bytes objs trace name
    1 97,26% 97,26% 268435488    2 414945632   22  8941 [B
    2  0,14% 97,40%   400064    4 1000160   10  4897 [B
    3  0,12% 97,53%   338640   20  338640   20  4596 [C
.....

TRACE 8941:
 
org/apache/tomcat/service/http/HttpResponseAdapter.printHead(HttpResponseAda
pter.java:186)
 
org/apache/tomcat/service/http/HttpResponseAdapter.endHeaders(HttpResponseAd
apter.java:116)
 
org/apache/tomcat/core/BufferedServletOutputStream.sendHeaders(BufferedServl
etOutputStream.java:126)
 
org/apache/tomcat/core/BufferedServletOutputStream.reallyFlush(BufferedServl
etOutputStream.java:236)
 
org/apache/tomcat/core/BufferedServletOutputStream.write(BufferedServletOutp
utStream.java:185)
        java/io/OutputStreamWriter.write(OutputStreamWriter.java:184)
        java/io/OutputStreamWriter.write(OutputStreamWriter.java:208)
        java/io/PrintWriter.write(PrintWriter.java:213)
        java/io/PrintWriter.write(PrintWriter.java:229)
 
org/apache/tomcat/facade/ServletWriterFacade.write(ServletWriterFacade.java:
120)


Two byte arrays allocate 260MB!!!!


I also do NOT use setBufferSize() or anything similar. Maybe the
HttpResponseAdapter.recycle()
method, which resets the bufferCounter is not called properly?

Help would be really apreciated!



> -----Ursprüngliche Nachricht-----
> Von: Craig R. McClanahan [mailto:craigmcc@apache.org]
> Gesendet: Freitag, 12. Oktober 2001 18:00
> An: tomcat-dev@jakarta.apache.org
> Betreff: Re: memory leak?
> 
> 
> 
> 
> On Fri, 12 Oct 2001, David Frankson wrote:
> 
> > Date: Fri, 12 Oct 2001 10:21:59 -0500
> > From: David Frankson <df...@qwest.net>
> > Reply-To: tomcat-dev@jakarta.apache.org
> > To: tomcat-dev@jakarta.apache.org
> > Subject: memory leak?
> >
> >     I've been using Tomcat 3.2.3 in a production environment for a
> > couple months without a problem.  Last week I added a new 
> feature and
> > now the tomcat process will consume memory until it reaches the
> > -Xmx512 size I have set.
> >
> > I ran the same webapp under Tomcat 4.0 and I see the same behavior.
> > However, I ran the same webapp under resin 2.0.2 and there is no
> > evidence of a memory leak.
> >
> > I downloaded JProbe to take a look at the heap, and the most
> > interesting thing I found was that there was a 33Mb byte[] 
> referenced
> > by HttpResponseAdapter.  I didn't see any objects from my 
> application
> > code that weren't supposed to be there.
> >
> > Has anyone encountered something like this?  What in my application
> > can cause Tomcat to hold onto memory and never release it?
> >
> 
> I don't know if this is what's going on in your case, but 
> here is one way
> this could happen.
> 
> The application gets to set the size of the response buffer (i.e. the
> amount of stuff you can write without committing the response 
> first), by
> calling response.setBufferSize().  It is also legal for the 
> container to
> give you back a buffer bigger than the one you asked for -- 
> so it may be
> that the container keeps reusing the same buffer from then 
> on.  Is there
> any chance that your application did a setBufferSize() with a 
> very large
> value somewhere along the way?
> 
> > Dave Frankson
> >
> 
> Craig
> 
> 

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