Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@jakarta.apache.org Received: (qmail 83722 invoked by uid 500); 6 Jul 2001 11:53:55 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: tomcat-user@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 83714 invoked from network); 6 Jul 2001 11:53:53 -0000 Received: from unknown (HELO snax.thwt.com) (216.215.228.131) by h31.sny.collab.net with SMTP; 6 Jul 2001 11:53:53 -0000 Received: by snax.thwt.com with Internet Mail Service (5.5.2448.0) id ; Fri, 6 Jul 2001 07:16:50 -0400 Message-ID: From: Randy Layman To: tomcat-user@jakarta.apache.org Subject: RE: creating a instance of a servlet: takes too long!! Date: Fri, 6 Jul 2001 07:16:49 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2448.0) Content-Type: text/plain; charset="iso-8859-1" X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N Really it depends upon what you are doing in your init method. I have several servlets that load almost instantly, but don't do anything in their constructor or init methods. The only thing that you should do in your init method is to call super.init at the beginning. If you want to move the time it takes to initialize, you could use the web.xml's load-on-startup tag (see the spec for more details) to load the servlet at Tomcat startup. You servlet should stay in memory until its shutdown - Tomcat keeps a reference to the servlet, thus preventing it from being garbage collected. The only reason, I believe, that a servlet is unloaded during the middle of Tomcat execution is a newer version is detected on disk. Randy > -----Original Message----- > From: pedro salazar [mailto:pedro-b-salazar@ptinovacao.pt] > Sent: Friday, July 06, 2001 5:02 AM > To: tomcat-user@jakarta.apache.org > Subject: creating a instance of a servlet: takes too long!! > > > Greetings, > > why is that my servlet when the first time is invoked, it > takes about 30 > seconds or more to start when the servlets that came in tomcat are > instantaneous? After the servlet container instantiated and > initialized my > servlet, all the following requests are very fast. Is there > any advice for > what we should do and don't do in init() method? I just > initialize some > properties and a connection pool.... > Well is it possible that my servlet container at any time my > may shutdown my > servlet to release memory, and another time it will be > requested to start > again and take another time too long to start, correct? > > How can I benchmark the time of instantiation of my servlet > and the time of > my init method? > > System configuration: > -Tomcat 3.2.1 > -JDK 1.3 > -Linux RedHat 6.2 [kernel 2.2.18] > -PII400Mhz 256Mbytes > > thanks. > -- > > > >