You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Tom Amiro <ta...@mediaone.net> on 2001/06/17 22:32:43 UTC

serious problem with Tomcat JVM running out of memory

Hello,

I am at the end of my rope. A couple of weeks ago, I tried to deploy a Java servlet
that gets about 300-400 hits a day using Tomcat in stand-alone mode
and Tomcat keeps running out of memory and crashing.  The servlet does an XSLT transformation
on an XML file about 1.5MB large. I was planning on integrating Tomcat into the main Apache
server after finishing the development, but haven't been able to get that far.

I've tried a lot of things and collected a lot of data, but have not been able to prevent
the Tomcat heap from growing and growing, until TC crashes.  The terminal
window shows lots of out-of-memory messages coming from the servlet before
the crash -- so I know it is servlet. Tomcat is only running the servlet (that gets
300-400 hits a day) and some JSP data entry tools used to maintain the XML file.
I've found that even when we refrain from using the data entry tools, and just
let the servlet run the problem still happens. The JSPs add to it, but even  with
them out of the picture, the situation is untenable.

I've spent more than 6 months developing this application -- an event
calendar -- and was forced to put it into production before it was tested.
But Java servlets and JSPs are supposed to make it easier to create web
applications, right?

At first, I thought I must be something wrong. So I did every thing I could
to plug memory leaks in my code. The thing that really perplexes me is that
the heap -- (rt.totalMemory()-rt.freeMemory() --will hover around 75M for
quite a while and then seem to jump in leaps and bounds -- sometimes 5-10MB at a time.

In the very beginning, I sent mail to the users group and have implemented
suggestions, like increasing the file descriptors to 1024, minimizing sessions
(session.setMaxInactiveInterval(120), starting the Tomcat JVM with more
memory (-Xmx160m).  That has helped somewhat. It takes longer to
crash with a 90MB core file filling up my /usr/local partition, but it hasn't
stayed up more than 24 hours.

Here's the configuration:

  - Solaris 2.7 on an Ultra-2 with all the patches.
  - one processor with 512MB memory
  - Java 1.3 is installed
  - Tomcat 3.2.2 jars
  - Session timeout 120 seconds
  - Using the thread pool with
    max_threads 25
    max_spare_threads 10
    min_spare_threads 5

I've started the TC JVM from the command line and done Ctrl-\,
but my telnet application's buffer isn't big enough to capture the
highest session, and I don't know what to look for.

I've been using the 'top' command to monitor the Tomcat
process. It shows the memory going up and up. Not sure
how to read it. With the max heap set to 160M, I've seen top
show the SIZE get up to 215M before the crash. Right now
its at 156M SIZE 52M RES.

>From time to time this error keeps popping up.

2001-06-17 04:10:36 - ContextManager: SocketException reading request, ignored -
 java.net.SocketException: Connection reset by peer
        at java.net.PlainSocketImpl.socketAvailable(Native Method)
        at java.net.PlainSocketImpl.available(PlainSocketImpl.java:451)
        at java.net.SocketInputStream.available(SocketInputStream.java:137)
        at org.apache.tomcat.service.http.HttpConnectionHandler.processConnectio
n(HttpConnectionHandler.java:217)
        at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java: 416)
        at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java
:501)
        at java.lang.Thread.run(Thread.java:484)


I've attached files to show you the servlet (Transform.java) and the
configuration files.

What should I do next? There has got to be a way to get this to work.

Please make sure to send email to me and not just to the dev alias,
as I'm not on the dev alias.
tamiro@mediaone.net

Thanks,

Tom








AW: serious problem with Tomcat JVM running out of memory

Posted by Thomas Bezdicek <th...@engnetworld.com>.
Hi, have you tried to set java memory parameters in tomcat.sh
at TOMCAT_OPTS (e.g. -Xmx256m -Xms128m).
We are running a quite large application without problems
after setting these parameters.

regards, tom

btw: what xslt-processor do you use, cause we are experiencing
an enormous performance leak using xalan compared to ms-xml
(40 sec to 3 msec!!!!) xalan on solaris 8 440Mhz, ms-xml on
w2k P3-850.

> -----Ursprungliche Nachricht-----
> Von: Tom Amiro [mailto:tamiro@mediaone.net]
> Gesendet: Sonntag, 17. Juni 2001 22:33
> An: tomcat-dev@jakarta.apache.org
> Cc: tamiro@mediaone.net; tamiro@east.sun.com; kevinm@coolrunning.com
> Betreff: serious problem with Tomcat JVM running out of memory
>
>
> Hello,
>
> I am at the end of my rope. A couple of weeks ago, I tried to
> deploy a Java servlet
> that gets about 300-400 hits a day using Tomcat in stand-alone mode
> and Tomcat keeps running out of memory and crashing.  The servlet
> does an XSLT transformation
> on an XML file about 1.5MB large. I was planning on integrating
> Tomcat into the main Apache
> server after finishing the development, but haven't been able to
> get that far.
>
> I've tried a lot of things and collected a lot of data, but have
> not been able to prevent
> the Tomcat heap from growing and growing, until TC crashes.  The terminal
> window shows lots of out-of-memory messages coming from the servlet before
> the crash -- so I know it is servlet. Tomcat is only running the
> servlet (that gets
> 300-400 hits a day) and some JSP data entry tools used to
> maintain the XML file.
> I've found that even when we refrain from using the data entry
> tools, and just
> let the servlet run the problem still happens. The JSPs add to
> it, but even  with
> them out of the picture, the situation is untenable.
>
> I've spent more than 6 months developing this application -- an event
> calendar -- and was forced to put it into production before it was tested.
> But Java servlets and JSPs are supposed to make it easier to create web
> applications, right?
>
> At first, I thought I must be something wrong. So I did every
> thing I could
> to plug memory leaks in my code. The thing that really perplexes
> me is that
> the heap -- (rt.totalMemory()-rt.freeMemory() --will hover around 75M for
> quite a while and then seem to jump in leaps and bounds --
> sometimes 5-10MB at a time.
>
> In the very beginning, I sent mail to the users group and have implemented
> suggestions, like increasing the file descriptors to 1024,
> minimizing sessions
> (session.setMaxInactiveInterval(120), starting the Tomcat JVM with more
> memory (-Xmx160m).  That has helped somewhat. It takes longer to
> crash with a 90MB core file filling up my /usr/local partition,
> but it hasn't
> stayed up more than 24 hours.
>
> Here's the configuration:
>
>   - Solaris 2.7 on an Ultra-2 with all the patches.
>   - one processor with 512MB memory
>   - Java 1.3 is installed
>   - Tomcat 3.2.2 jars
>   - Session timeout 120 seconds
>   - Using the thread pool with
>     max_threads 25
>     max_spare_threads 10
>     min_spare_threads 5
>
> I've started the TC JVM from the command line and done Ctrl-\,
> but my telnet application's buffer isn't big enough to capture the
> highest session, and I don't know what to look for.
>
> I've been using the 'top' command to monitor the Tomcat
> process. It shows the memory going up and up. Not sure
> how to read it. With the max heap set to 160M, I've seen top
> show the SIZE get up to 215M before the crash. Right now
> its at 156M SIZE 52M RES.
>
> >From time to time this error keeps popping up.
>
> 2001-06-17 04:10:36 - ContextManager: SocketException reading
> request, ignored -
>  java.net.SocketException: Connection reset by peer
>         at java.net.PlainSocketImpl.socketAvailable(Native Method)
>         at java.net.PlainSocketImpl.available(PlainSocketImpl.java:451)
>         at
> java.net.SocketInputStream.available(SocketInputStream.java:137)
>         at
> org.apache.tomcat.service.http.HttpConnectionHandler.processConnectio
> n(HttpConnectionHandler.java:217)
>         at
> org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java: 416)
>         at
> org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java
> :501)
>         at java.lang.Thread.run(Thread.java:484)
>
>
> I've attached files to show you the servlet (Transform.java) and the
> configuration files.
>
> What should I do next? There has got to be a way to get this to work.
>
> Please make sure to send email to me and not just to the dev alias,
> as I'm not on the dev alias.
> tamiro@mediaone.net
>
> Thanks,
>
> Tom
>
>
>
>
>
>
>
>