Classes not unloading correctly?

Jacob Kessler Jacob.Kessler at Sun.COM
Fri Jun 12 20:05:29 UTC 2009

I'm working on the GlassFish scripting project, trying to solve an issue 
with the PermGen around deploying and undeploying applications.

We use an embedded JRuby interpreter to host each deployed Ruby 
application, and JRuby makes extensive use of JIT-ed classes to improve 
performance. A typical JRuby instance takes roughly 20MB of permgen. 
We'd like for that space to be reclaimed once the application is 
undeployed, since losing 20MB of permgen each time an application is 
deployed puts a fairly hard limit on the number of redeploys that the 
server can take before it has to be restarted.

We started out using -XX:+UseConcMarkSweepGC and 
-XX:+CMSClassUnloadingEnabled, and with the aid of a memory analysis 
tool (YourKit), we confirmed that some classes were being unloaded (not 
a significant number, though), and we tracked down and fixed two things 
that were improperly holding references to the classloader that 
contained JRuby. After fixing those, though, we ended up in a situation 
where YourKit was reporting the classes as still in memory after a 
forced full collection, but as having no paths to the GC roots. This 
situation seemed able to persist indefinitely (so, beyond time for the 
finalizer queue to drain). Does anyone have any ideas on what might be 
preventing the classloader from collecting?

I'm using
$java -version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) 64-Bit Server VM (build 10.0-b23, mixed mode)

Thank you for any help with this.

hotspot-gc-use mailing list
hotspot-gc-use at

More information about the hotspot-gc-dev mailing list