On Mon, 10 Apr 2000, Sam Heisz wrote:
>
> "JDK 1.1.x specification added the feature of class unloading...
> where the only reference to the Singleton object is maintained within
> the Singleton class itself, the garbage collector, in its enthusiasm to
> dispose of any unused trash, may assume that the Singleton is
> unreachable because no other object or class holds a current reference
> to it and could quite legally garbage collect the object and unload the
> class...'
>
> It goes on to mention that you either have to maintain a reference to
> the Singleton somewhere, or use the -noclassgc flag to disable class
> unloading.
The spec states "A class may not be unloaded while any instance of it
is still reachable. A class or interface may not be unloaded while the Class
object that represents it is still reachable."
The first clause of that seems to imply that a singleton would be saved
from GC because its class object will never be collected, even if the
ClassLoader that loaded it in the first place (as in the case of JSPs)
gets dumped. So effectively you would end up with a special cluster
(class and singleton instance) that is valid and not subject to garbage
collection but are not part of the root tree of references -- hence
Craig's assertion that this is more of a forest than a tree.
Wes
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets