You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "H.F.N. den Boer" <ni...@denboer-ims.nl> on 2001/04/19 11:42:41 UTC

Cleaning up servlets

When a servlet is destroyed, I log a number of things.
>From the log I conclude that servlets are only destroyed when the NT service is
shut down manually.

Do I need to run a separate process (thread) to monitor how long a servlet is
not used and from that process destroy it or is there some other way to keep my
environment clean ? Maybe a Tomcat setting ?

I'm working with;
Win2K server, build 5.00.2195
IIS 5.0, configured with ISAPI filter
JDK1.3.1beta
Tomcat 3.2.1 running as NT service

Nico


Re: Cleaning up servlets

Posted by Sam Newman <sa...@stamplets.com>.
Well, the servlet will get destroyed when the servelet is garbage collected
I think. The JVM has a garbage collection thread which starts up
automatically, and its its job to  cleanup unused objects. I'm not sure if
this behaviour changes in tomcat. You can explicitly call the garbage
collector by calling System.gc(),or something similar.
Note that something will only be garbage collected when nothing holds any
references to it (an  oversimplification I know). If you simply want to free
some resources up after a servlet is used, do this in your doPost/doGet
methods.

sam
----- Original Message -----
From: "H.F.N. den Boer" <ni...@denboer-ims.nl>
To: "Tomcat users group" <to...@jakarta.apache.org>
Sent: Thursday, April 19, 2001 10:42 AM
Subject: Cleaning up servlets


> When a servlet is destroyed, I log a number of things.
> >From the log I conclude that servlets are only destroyed when the NT
service is
> shut down manually.
>
> Do I need to run a separate process (thread) to monitor how long a servlet
is
> not used and from that process destroy it or is there some other way to
keep my
> environment clean ? Maybe a Tomcat setting ?
>