Hi, > -----Original Message----- > From: Thomas ?hlen [mailto:[EMAIL PROTECTED]] > Sent: Friday, February 15, 2002 4:11 PM > To: Tomcat Users List > Subject: Problems with Manager reload, memory usage and garbage > collection. > > > Each time I reload my application with the Manager servlet the > memory usage > increase. > > Spec: I have Tomcat 4.0.2 and JDK 1.3.1_02 running on a Windows2k machine. > > I have located my problem using JProbe with Tomcat 4.0.2. Looking at the > instance summary before and after a reload I see that there is one class > that isn't GC'd. So after 10 reloads I have 10 instances of this > class. The > class is a singelton and lookes something like this: > > public class MySingelton > { > private static MySingelton singelton; >
Above is the reference that don't let your class to be GC'ed. You should add something like close() to your class public void close() { singleton = null; } and then call it in your servlet's destroy() > private Hashtable resources; > > private MySingelton() > { > // Create a Hashtable with some resources here > } > > public static Object getResource( String name ) > { > return resources.get( name ); > } > > public static synchronized void configure() > { > singelton= new MySingelton(); > } > } > > This Singelton are only called in the init method of my servlet; e.g. > > public void init( ServletConfig config ) > throws ServletException > { > MySingelton.configure(); > } > > > I guess that Tomcat sets up a new ClassLoader each time an application is > reloaded. So why can't MySingelton be garabage collected? Somewhere there > must still be a reference to it and it isn't in my code for sure. > > Please anyone got a suggestion how to solve my problem? > Hope it helps. > Thanks! > Thomas ?hl?n > > Anton -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]>