> From: Christopher Schultz [mailto:[EMAIL PROTECTED] 
> Subject: Re: Garbage Collection and Class unloading
> 
> This used to happen because Class objects were never 
> discarded by the JVM.

That's not true, at least not since JVM 1.2 came into use.  Class
objects are discarded once there are no more instances of that type,
there are no references to the Class objects themselves, and class
unloading has not been inhibited by command-line option.

> using static fields to store big object trees and pushing 
> application data into something managed by Tomcat (JNDI, a
> Valve, or something like that).

There have also been related issues with other oft-used non-Tomcat
libraries, such as loggers. Not sure if all of this undesired references
have been cleaned up.

> The ClassLoader keeps all the java.lang.Class objects
> it ever loaded

Actually, the references go the other way - every instance of
java.lang.Class retains a pointer to its ClassLoader, and the
ClassLoader won't be discarded until all of its loaded classes are gone.
(It's possible that Tomcat's WebappClassLoader keeps track of all
classes it loads - I haven't checked - but the standard ClassLoader
implementations that come with the JRE do not.)  Individual instances of
java.lang.Class can be discarded at any time, as long as the constraints
noted above are complied with.

> and those will eventually go into the PermGen space 
> due to their long lives.

All instances of java.lang.Class are allocated within the PermGen from
the get-go; there is no migration into or out of PermGen.  (The tenured
generation does operate as you describe.)

> I'm a little hazy on PermGen, actually, but I think it 
> /never/ gets cleaned up.

Not true, except if one esoteric, non-standard GC algorithm is selected
for the HotSpot JVM.  PermGen is cleaned up whenever a full collection
occurs.

> Second, class loading and GC are mostly unrelated

Not true - they're intimately connected.  Note that it takes two full
GCs to get rid of java.lang.Class instances after they become
unreachable.  The first discovers that they're no longer active and
queues the instances for some cleanup processing.  The instances
themselves are not discarded until the next full GC, after the cleanup
has happened.

> Yes. You might even want to do -verbose:class if you want 
> some light reading.

At least reading it won't keep you awake...

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to