You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Morten <mo...@bilpriser.dk> on 2007/09/06 08:15:03 UTC
Tomcat memory issues
Hi
We have implemented a picture/pdf server in Tomcat.
The pictures are cached in a map. When the memory is nearly full, some
entries are removed from map.
However, eventually the entries in the map become fewer and fewer even
though the memory consumption stays high. In other words more and more
memory are used outside the map.
According to a heap dump done by jmap, there are many
org.apache.tomcat.util.buf.ByteChunk instances referencing large byte[],
which we suspect to be previously used pictures.
We have tried both Tomcat 5.5.9 and Tomcat 6 under JBoss 4.2.0. Both showed
the same behaviour.
Are there any way to stop Tomcat from cached these large byte[] internally?
The object graph looks like this:
The byte[] is referenced from:
- ByteChunk (A)
- ByteChunk (B)
ByteChunk (A) is referenced by:
- org.apache.tomcat.util.buf.C2BConverter (AA)
- org.apache.tomcat.util.buf.IntermediateOutputStream (AB)
- org.apache.catalina.connector.OutputBuffer (AC)
ByteChunk (B) is referenced by:
- org.apache.catalina.connector.OutputBuffer (AC)
C2BConverter (AA) is referenced by:
- HashMap$Entry (AAA)
- org.apache.catalina.connector.OutputBuffer (AC)
IntermediateOutputStream (AB) is referenced by:
- org.apache.tomcat.util.buf.C2BConverter (AA)
- org.apache.tomcat.util.buf.WriteConvertor (ABA)
- sun.nio.cs.StreamEnocder (ABB)
OutputBuffer (AC) is referenced by:
- org.apache.catalina.conncetor.CoyoteOutputStream (ACA)
- org.apache.catalina.connector.CoyoteWriter (ACB)
- org.apache.catalina.connector.Response (ACC)
HashMap$Entry (AAA) is referenced by:
- <class>[]
org.apache.catalina.conncetor.CoyoteOutputStream (ACA) is referenced by:
- org.apache.catalina.connector.Response (ACC)
org.apache.catalina.connector.CoyoteWriter (ACB) is referenced by:
- org.apache.catalina.connector.Response (ACC)
org.apache.catalina.connector.Response (ACC) is referenced by:
- org.apache.catalina.connector.ResponseFacade (ACCA)
- <class>[] (ACCB)
- org.apache.catalina.connector.Request (ACCC)
I cannot find any trace of any JBoss or any webapp class.
Any help appreciated,
Morten
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat memory issues
Posted by Peter Warren <to...@gmail.com>.
> As far as I under stand I should NOT close the "stream" object as I didn't
> open it.
That's my understanding too. When I said I was keeping connections
open, I meant I was opening connections from the client and not
closing them. Since I'm using comet servlets, the server keeps the
connections open until the client disconnects. When I open many
connections, I see classes in my heap similar to those you show.
If you keep a reference to the Request object tucked away somewhere on
the server inadvertently, the associated buffers won't go away and
memory will continue to grow. Is it possible that you're keeping a
reference to the Request or any of the "streams" somewhere? Is it
possible that some of your servlets aren't returning and thus never
closing their connections?
What classes are holding references to these classes?
- org.apache.catalina.connector.ResponseFacade (ACCA)
- <class>[] (ACCB)
- org.apache.catalina.connector.Request (ACCC)
Peter
On 9/7/07, Morten <mo...@bilpriser.dk> wrote:
>
> "Peter Warren" <to...@gmail.com> skrev i en meddelelse
> news:176a7eb80709060858q403b6fe0p993c48e2fcc5069c@mail.gmail.com...
> > Is it possible you're caching Request or Response objects somewhere
> > and not releasing them? I just did a bunch of memory profiling and
> > many of the classes you mention are the same classes I see when I open
> > and don't close a bunch of connections to the server.
> >
> My code in the bottom of the servlet is such:
>
> ServletOutputStream stream = _response.getOutputStream();
> BufferedOutputStream bos = new BufferedOutputStream(stream);
> bos.write(bytes);
> stream.flush();
> bos.close();
>
> As far as I under stand I should NOT close the "stream" object as I didn't
> open it.
>
> Best regards,
>
> Morten
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat memory issues
Posted by Morten <mo...@bilpriser.dk>.
"Peter Warren" <to...@gmail.com> skrev i en meddelelse
news:176a7eb80709060858q403b6fe0p993c48e2fcc5069c@mail.gmail.com...
> Is it possible you're caching Request or Response objects somewhere
> and not releasing them? I just did a bunch of memory profiling and
> many of the classes you mention are the same classes I see when I open
> and don't close a bunch of connections to the server.
>
My code in the bottom of the servlet is such:
ServletOutputStream stream = _response.getOutputStream();
BufferedOutputStream bos = new BufferedOutputStream(stream);
bos.write(bytes);
stream.flush();
bos.close();
As far as I under stand I should NOT close the "stream" object as I didn't
open it.
Best regards,
Morten
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat memory issues
Posted by Peter Warren <to...@gmail.com>.
Is it possible you're caching Request or Response objects somewhere
and not releasing them? I just did a bunch of memory profiling and
many of the classes you mention are the same classes I see when I open
and don't close a bunch of connections to the server.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat memory issues
Posted by Dwayne <dw...@gmail.com>.
If you don't want to cache internally then you need a distributed caching
scheme.
There is an open source solution from the guys at Terracotta.org they call
Network Attached Memory. Basically you can deploy a virtual heap against
disk and make your memory as big as you want. They built all sorts of drop
in config modules already:
https://wiki.terracotta.org/confluence/display/integrations/Home.
Hope this helps.
Dwayne
Go Open Source
On 9/6/07, Caldarale, Charles R <Ch...@unisys.com> wrote:
>
> > From: news [mailto:news@sea.gmane.org] On Behalf Of Morten
> > Subject: Tomcat memory issues
> >
> > Are there any way to stop Tomcat from cached these large
> > byte[] internally?
>
> If you look near the end of conf/catalina.properties, you'll see some
> caching enable/disable lines; you might try turning off the one for byte
> and see what happens. I haven't tried this, so I don't really know if
> it will help or what effect it will have on performance or any other
> operational characteristic.
>
> - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
RE: Tomcat memory issues
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: news [mailto:news@sea.gmane.org] On Behalf Of Morten
> Subject: Tomcat memory issues
>
> Are there any way to stop Tomcat from cached these large
> byte[] internally?
If you look near the end of conf/catalina.properties, you'll see some
caching enable/disable lines; you might try turning off the one for byte
and see what happens. I haven't tried this, so I don't really know if
it will help or what effect it will have on performance or any other
operational characteristic.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org