You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Maia Hansen <ma...@mindseye.com> on 2000/11/10 15:34:29 UTC

Does Tomcat unload unused servlets?

Hi, all!

Wondering if anyone out there knows if Tomcat automatically unloads
servlets which haven't been hit for X amount of time (and, if so, whether X
can be configured).  

I have a servlet which takes a bit of time to load, and I'm trying to avoid
having users ever see that delay, so I'd like to keep it loaded
indefinitely (assuming this is not currently the default behaviour, which
it may be -- I haven't tested any of this).  (And yes, I'm playing God, but
it's the only servlet Tomcat's serving, so I feel justified.)

Thanks!

--maia

Re: Does Tomcat unload unused servlets?

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Maia Hansen wrote:

> Hi, all!
>
> Wondering if anyone out there knows if Tomcat automatically unloads
> servlets which haven't been hit for X amount of time (and, if so, whether X
> can be configured).
>
> I have a servlet which takes a bit of time to load, and I'm trying to avoid
> having users ever see that delay, so I'd like to keep it loaded
> indefinitely (assuming this is not currently the default behaviour, which
> it may be -- I haven't tested any of this).  (And yes, I'm playing God, but
> it's the only servlet Tomcat's serving, so I feel justified.)
>

Versions of Tomcat up through and including 4.0 do *not* unload inactive
servlets.  The only time servlets are unloaded is when you shut Tomcat down, or
when your webapp is set for auto-reloading and it gets triggered.

However, the servlet spec does *not* guarantee this behavior, and there is
likewise no guarantee that it won't change in future versions.

However, the new Servlet 2.3 API (which Tomcat 4.0 implements) offers a new
feature designed to deal with cases like this:  application events.  You can
register an event listener class that is notified when the application is
started, or when it is stopped -- completely independent of the lifetime of
servlets within that app.  This is perfect for lengthy one-time initializations
that you want to have done at startup time (the results can be stored in
servlet context attributes to make them available to the servlets and JSP pages
in your app).

Craig McClanahan


>
> Thanks!
>
> --maia