tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <>
Subject RE: [partially off topic] How can I detect java.lang.OutOfMemoryError
Date Tue, 15 Apr 2003 16:12:23 GMT

This is a very uphill battle, if it's tractable at all.  

>From the JavaDoc for java.lang.Error:
"An Error is a subclass of Throwable that indicates serious problems that a reasonable application
should not try to catch."

Nothing inside Tomcat (indeed nothing in general AFAIK) declares itself as throwing an OutOfMemoryError.
 So the best you could do is surround the whole thing that controls tomcat (I'm assuming you're
using Embedded tomcat?) in a big try { } catch (Throwable t) clause.  

Inside the catch, look to see if t is instanceof OutOfMemoryError.  If that's the case, do
whatever you want, otherwise propagate it (throw t).

This is a risky, non-standard approach.  I think you would be better served in the long term
to configure the server or the apps running on it such that it doesn't run out of memory.

Yoav Shapira
Millennium ChemInformatics

>-----Original Message-----
>From: Reynir Hübner []
>Sent: Tuesday, April 15, 2003 11:49 AM
>To: Tomcat Users List
>Subject: [partially off topic] How can I detect java.lang.OutOfMemoryError
>I am trying to find a good way to detect and handle
>There are obvious problems to this, if this error occures the VM is
>basically "crashed" but not dead, it cannot allocate more memory.
>I would like to handle such errors by sending an email to the system
>administrator and restarting the service running tomcat, and maybe even add
>few megabytes to the Xmx JVM parameter.
>Just for the record, I know what causes the OutOfMemoryError, and it's not
>really an error or anything, it's just pure load, and of course it's always
>possible to adjust some things around the server, for example shorten the
>session timeouts, so sessions data would be garbage-collected faster.
>As I said the server is under a lot of continuous load, and this error
>happens when someone does something very memory-demanding, for example I've
>seen it happen when using the reload function in the manager application.
>So, now I'm wondering what is the best way of detecting the error ?
>I'm using windows 2000 servers...
>To unsubscribe, e-mail:
>For additional commands, e-mail:

This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message