tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Vávra <>
Subject Re: Tomcat recycling
Date Mon, 21 Nov 2011 13:24:10 GMT

>> Hello,
>> is there any way how to tell tomcat: Recycle after X minutes OR Y requests like it
is eg. on the IIS server?
> IIS can reboot itself after N requests?
> That's awesome. What could possibly go wrong?

Yes, IIS can do recycling
See eg. at
It is a quite easy to setup it in the configuration.

> I might file an enhancement request for Tomcat...
If you have already done it, can I vote it for?

>> If I add my own script containing "/etc/init.d/tomcat restart"  to the crontab I
loose the user sessions and users have to relogin.
> Yes... because you restarted the server!
As Chris Schultz wrote it is possible to persist sessions over tomcat 
restarts. I chagned my session objects to be serializable and It works.

>> I experience some problems with OutOfMemory error.
> Wouldn't it be better to understand and fix the OOM, rather than just
> rebooting the server frequently?

Yes, it is allways better to solve the cause than the consequence of a 
problem. But not allways man can have enough time or means to solve it. 
When an error occurs at production it is better to setup some kind of 
recovery (eg. recycling) and than solve it at pre-production / devel 
environment. You can use a third party lib with an error.

Particulary in my case, my app consists of a one single cycle where I 
download a CRL, parse it using BouncyCastle lib and retrieve serial 
numbers of revoked certificates. So the problem can rather in third 
party lib than in my small piece of code. I've tried to profile memory 
consuption but have not found out nothing. Maybe I had had not enough 
memory for java virtual machine. I've set it from 128 MB to 512 MB and 
the problem have not occured yet.

>> On tomcat I run a periodic thread that downloads CRLs and I suspect this of memory
> Why? Can't you fix that?

If we forget the OOM exception, I was forced to make a ShutDownHook. I 
use spring quartz scheduler and my job can run quite a long time. So I 
had to add some notification to stop job correctly. Tomcat was 
complainting about possible memory leaks when ending quartz job-worker 
threads when I was stopping app for redeploy my app. In a single process 
model (crontab) I could afford to kill -9 the process and I could rely 
on transactionality in the database which I'm using.

At the end I'd like to make a little comparision. Recently I've used 
.NET + native calls of dlls, php + custom made php modules (native 
dlls), jsp+java. .NET and php have possibilities for some kind of 
recoveries. It's almost imposible to crash Apache like a whole (control 
+ x worker processes). So .NET and php seems me they're more stable than 
tomcat because they have some possibilites. I haven't studied recovery 
options in other java app. servers, but I'd really appriciate something 
in Tomcat.


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

View raw message