I've read so many Q&A here about tools available to find out unused JARs, such as:
My question here is, are there any impacts (such as loading of classes into memory, performance, etc.) of having unused JARs in the classpath either at compile time or run time? Question applies to both running as a Standalone program and Web Server (Apache Tomcat), though I initially thought about only Standalone programs.
NOTE: I'm running JDK 6u32 (64-bit).
Are there any impacts (such as loading of classes into memory, performance, etc.) of having unused JARs in the classpath either at compile time or run time?
There is going to be a small impact. When the class loader (or the compiler's equivalent) starts, it has to read the index of each JAR file to find out what classes are in each JAR. If you've got unnecessary JARs on the classpath, the classloader has more work to do, and will (at least temporarily) use more memory to cache the indexes.
This applies to all kinds of Java application.
The question that you didn't ask is whether the impact is significant. The answer is "generally no" ... but the more "useless stuff" you have on the classpath, the greater the impact is going to be.
The main problem is not performance as the cost is relatively small and only on loading new classes. The main problem is maintainability. For example, when a library needs to be upgraded, you can waste alot of time testing the application still works ok with the new version only to find the library was not used. (Say you have a new library which needs a newer version of a library you are already "using")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With