Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@apache.org Received: (qmail 81185 invoked from network); 3 Jan 2003 14:05:46 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 3 Jan 2003 14:05:46 -0000 Received: (qmail 1650 invoked by uid 97); 3 Jan 2003 14:06:42 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-user@jakarta.apache.org Received: (qmail 1610 invoked by uid 97); 3 Jan 2003 14:06:41 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Users List" Reply-To: "Tomcat Users List" Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 1572 invoked by uid 98); 3 Jan 2003 14:06:39 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: Release of memory Date: Fri, 3 Jan 2003 09:03:18 -0500 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Release of memory Thread-Index: AcKzJ7cMEamVyyWXSoKd47M1NvFaGgACLgwA From: "Shapira, Yoav" To: "Tomcat Users List" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi, >However, what does tomcat do after the "service" method returns? The >Servlet interface has a "destroy" method, is it used? Why doesn't Tomcat >release the servlet instance? Can anyone explain the reason? The servlet container is free to destroy servlets and JSPs at will. Tomcat does not currently do this. Assuming you want your code to be portable, it shouldn't be rely on whether the container unloads your servlets or not. In general, don't rely on destroy() methods in servlets to free memory. Most of your servlet's object allocation (and de-allocation) should be in the various service() methods. The exception to this are things like DB connections, JNDI entries, etc that you want to create once (e.g. in the servlet's init() method) and hold for the servlet's lifetime. If you create objects in the service method and don't refer to them elsewhere, they'll eventually be GCed even though the servlet instance itself isn't destroyed. Yoav Shapira Millennium ChemInformatics -- To unsubscribe, e-mail: For additional commands, e-mail: