Reputation: 53
We are having a web application which depends on around 125 jars including spring, hibernet, zk, etc.
When we start the tomcat server, it loads around 55K classes into the permgen. Coz of this huge class loading, application startup takes significant amount of time. Moreover permgen space required by application is very high as other classes are also loaded during the program execution.
I had tried with -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled options specified for java. But only 42 classes were unloaded after sometime.
Any help or pointers are highly appreciated.
Upvotes: 3
Views: 2007
Reputation: 6547
The jars are in the classpath for a reason. They are probably added to you webapp through a build management system (maven, gradle, ...) - therefore there may be some dependencies to these jars.
Removing jars from the classpath will produce NoClassDefFoundError
. I guess you have to live with that amount of jars unless some of them are not needed (which is not easy to find out).
Best check you dependency graph (maven and gradle have them) for possibly redundant, not needed or obsolete jars in your project. Also check for jars that come in different version like random-1.0.0.jar
and random-1.0.1.jar
and exclude one of them if possible.
Upvotes: 1
Reputation: 41858
You may want to use a tool to remove unneeded classes.
This question dealt with this very issue:
Tool to remove unnecessary dependencies in a Java project
But this question on Oracle may be more useful:
https://forums.oracle.com/forums/thread.jspa?threadID=1311910
I think that GenJar2 (http://code.google.com/p/genjar2/) may best meet your needs though.
Upvotes: 0