tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Smith <>
Subject Re: Garbage Collection and Class unloading
Date Fri, 07 Sep 2007 02:03:21 GMT
Others with more experience in the garbage collection may chime in, but 
it's my impression that the garbage collection tends to have it's own 
mind.  You can try to force it, but that's no guarantee it will garbage 
collect anything.  I'd think your best bet is to clean out all the dead 
in-house code and then thin out the dependencies until it stops 
building.  If nothing else, refactor your code to pair down the multiple 
versions of libraries.


Brian Munroe wrote:
> Can someone explain a little bit about classloading really quick?
> Let me preface this with: I am maintaining an application which I did
> not develop.
> Looking at the WEB-INF/lib directory, it has around 76 different jar
> files, some actually used in the application, some (well, most) not.
> They either pertain to legacy features or are functionality duplicate
> (two different versions of Oracle driver libraries, for example)
> I am trying to tune Tomcat because it keeps running out PermGen space,
> so I am using jconsole to inspect the JVM.  I suppose it isn't really
> a profiler, but it is a start.
> According to jconsole, after doing many application development cycles
> of remove->deployment of *.war to Tomcat (via manager), it looks like
> as many as 20k classes are loaded.  I was under the impression that
> the garbage collector would unload classes as necessary.
> I tried to force a GC via jconsole, it reduced the heap memory like it
> should, and it unloaded a few classes pertaining to reflection, but
> nothing like what I was hoping for.  I then leave it be for several
> hours, and all magic like, the GC unloads about 4k classes.
> First question.   Anyone tell me why it doesn't unload classes when I
> am trying to force it?  Is classloading/unloading not even the same as
> garbage collection?
> Second question.  Is having 20k classes loaded normal for a middle
> sized application?  I am assuming if I remove all the unnecessary jars
> from WEB-iNF/lib I can reduce that number?  Would it benefit anything
> to place them in shared/lib?
> Third:  If over 75% of the classes in the jars aren't being called
> anywhere in the application, even though they get loaded on the
> initial application deployment, shouldn't the GC unload them almost
> immediately, since there aren't any open resources using these
> classes.
> Fourth question:  Do my JAVA_OPTS looks decent?
> JAVA_OPTS="-Xms512m -Xmx512m -server
> -verbose:gc
> -XX:+PrintClassHistogram
> -XX:+PrintGCDetails
> -XX:MaxPermSize=128m"
> many thanks!
> -- brian
> ps.  My platform looks like:  Solaris 9 (SPARC), Tomcat 5.5.23, JDK
> 1.6.0_02 (32-bit)
> ---------------------------------------------------------------------
> To start a new topic, e-mail:
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message