Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Library Size

If I'm given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is:

How will the larger, mostly unused library affect the application's performance? Does the JVM do lazy loading of classes, does having a larger class library necessarily mean a larger memory footprint?

like image 772
Allain Lalonde Avatar asked May 30 '26 11:05

Allain Lalonde


1 Answers

The short answer is that classes are loaded whenever they are first needed. Note that "needed" also means "referenced by any other class that is being loaded".

So if you have a whole pile of classes that are never touched by any active code, it will not be loaded.

If you would like to see exactly which classes the JVM is loading and when, you can invoke the java command/process with the -verbose:class option.

like image 178
matt b Avatar answered Jun 01 '26 00:06

matt b



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!