tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Crowther" <Peter.Crowt...@melandra.com>
Subject RE: Servlet inter-communication
Date Wed, 03 May 2006 14:00:02 GMT
> From: Leon Rosenberg [mailto:rosenberg.leon@googlemail.com] 
> Could you explain it a bit more? What's the difference whether I have
> 10 instances of the same class or just one for reloading?

In a Singleton:

- the class holds a reference to the classloader;

- the class holds a reference to the singleton instance;

- the instance holds a reference to the class.

My understanding is that classes cannot be GCed unless they have no
instances, and classloaders are (obviously) not collected until they
have no references from classes.  So singletons leave classes lying
around in your JVM.  More annoyingly, classes always occupy PermGen
space, so this junk class is now eating up precious space in PermGen -
hence the possibility of an OOME if you reload your webapp too many
times.  The solution is to implement appropriate listeners to make sure
the instance is not referenced by the class before the webapp is
unloaded.

That's a quick recap from memory.  I thoroughly expect Chuck to jump
into the conversation and point out where I've misinterpreted :-).

		- Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message