> From: Christopher Schultz [mailto:[EMAIL PROTECTED] 
> Subject: Re: Garbage Collection and Class unloading
> 
> I thought a lot of the talk on this list about PermGen was that it was
> filling up and never being cleaned-up. Maybe that was just folks
> legitimately keeping lots of data around for a long time.

More likely to be accidentally than legitimately.  As long as there are
references to a Class object or instances of the class around, the Class
object can't be removed.

> Loading a class into memory from bytes doesn't interact with
> the GC any differently than loading an array of bytes from
> any other file.

Actually it does.  It is true that every class eventually becomes a byte
array, but that byte array is passed to ClassLoader.defineClass(), which
registers it with GC.  At the end of a full collection, the class
registration list is examined for unreachable classes, which are then
removed from the list and sent off for cleanup.  Such cleanup includes
getting rid of any JIT-processed methods in the code cache, among other
internal JVM structures.  On the next full GC, such java.lang.Class
instances are no longer in the registration list and are simply
discarded like any other unreachable object.

> ClassLoaders themselves don't have any magic in them.

That's true, except for the native code behind the
ClassLoader.defineClass() method (which is final, so can't be overridden
by subclasses); all of this java.lang.Class manipulation occurs under
the covers in the non-Java core of the JVM.

 - 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