tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Cooke <cee...@cee.hw.ac.uk>
Subject OutOfMemoryError
Date Wed, 06 Aug 2003 16:02:42 GMT
Hi there,

We have a tomcat application that uses servlets to hold state on behalf
of API users - kind of like a database.

If API users store too much info, then eventually an OutOfMemoryError
results, and the servlet container crashes:


> 06-Aug-2003 16:34:45 org.apache.tomcat.util.log.CommonLogHandler log
> SEVERE: Caught exception executing org.apache.tomcat.util.net.TcpWorkerThread@163956,
terminating thread
> java.lang.OutOfMemoryError


Does any one know of a neat way of monitoring memory usage, so that our
servlet can decide to refuse a request if it senses that memory is about
to run out?

I thought at first we could simply monitor Runtime.getTotalMemory(),
etc. e.g. refuse request if:

(totalMemory - freeMemory) > some % of the maxMemory 

but it seems the situation is more complex.  These are the numbers just
before the crash:

free Memory = 172544, totalMemory = 6.6650112E7, maxMemory =
1.34217728E8

and I don't understand why the JVM didn't try to grab more memory when
it could - is it because one of tomcat's threads unexpectedly ran out of
memory that it should have been allocated?

thanks for any suggestions,

Andy Cooke 

-- 
Heriot-Watt University


Mime
View raw message