Janis Gailis wrote:
> Please see the comment between the lines.
>
> "Craig R. McClanahan" wrote:
>
> > Howard Lee wrote:
> >
> > > Hi,
> > >
> > > I'm new to Servlet, and have a question about its life span. From what I've
> > > read, servlets get loaded and it stays in web server's memory space. Does
> > > this mean servlets stay in JVM and never get garbage collected?? I know
> > > servlets have destroy method, and it gets called when the servlet gets
> > > garbage collected. So if servlets stay in JVM, these methods will never get
> > > called? Any help will be greatly appreciated. Thanks!
> > >
> >
> > The server has the option to throw out a servlet instance any time it wants to
> > (after calling the destroy() method). For instance, it might decide that it's
> > low on memory and servlet XYZ has not been called for a long time, so it can
> > free up memory by destroying that instance. In practice, most current servers
> > do this only when you are shutting down the server, or if auto-reloading when
> > a class changes (useful for development) is implemented.
> >
> > In between calls to init() and destroy() your servlet does stay in memory, but
> > there is only one object instance -- it is used to handle all requests from
> > all users that match the URL to which it is mapped.
>
> This is probably JServ specific, but I can not see that servlets started
> by the Apache and JServ behaves in this way.
>
> I access my servlet from different hosts and the init() is obviously
> executed for each of the requests (acording to my own logs and
> jserv.log from JServ classes). Auto-reloading is disabled
> (in my_zone.properties file from JServ).
>
My experience with Apache JServ (over two years) is that it behaves the way I
described. However, the meaning of "single instance" should be clarified -- it is
actually "single instance per servlet definition, within a particular servlet
context, which lives in a particular virtual host." If you define the same servlet
in multiple zones, or with multiple servlet definitions in your zone properties, or
attached to multiple virtual hosts, you're going to get separate instances.
Also, if you use SingleThreadModel then Apache JServ implements a pool of instances
per the configuration parameters in your zone properties file. Could that be the
case here?
>
> Can it be that the ThreadPool in JServ (with bugs) has smth. to do
> with this? I requested my servlets on Windows platform
> using JRun and Netscape Enterprise before and then they behaved like
> Craig described. So I switched to Linux and JServ and
> it seems that I have to face the actual problem now (a lot
> of users -> a lot of instances -> a lot of used memory -> ???).
>
> This is worth to discuss, if it is not discussed before, of course.
>
Your best bet would be to review the FAQs and mail list archives on the Apache
JServ web site <http://java.apache.org> and/or ask questions on the user list there
if you can't find the answer in the FAQs.
>
> janis
>
Craig McClanahan
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html