views:

69

answers:

2

I was wondering if the size of jar file has any implications for the peformance of the Java Virtual Machine?

Is there going to be a point where the jar file becomes too large that the JVM will not be able to function effectively?

A: 

In my opinion the size of the jar is not the factor to look at when trying to increase performances.

If you have big jars, it means you have lot of code. If you have lot of code because you are working on a complex project, all is ok for me. If you have big jars for a "simple" project it may means that the code need to be thinking again => Well designed classes are often the way to achieve the smaller code size and thus the smaller jars.

Manuel Selva
+6  A: 

Yes, the size of the jar file has implications on performance. The more appropriate question is, does it have any significant implications? The answer to that question is no.

Yes, there is a point where the jar file becomes too large and affects the JVM. I don't know where it is, but it's somewhere near the size of your system memory. If the JVM cannot load the entire JAR file and the Java libraries in system memory without swapping, this will certainly affect performance.

This isn't something you need to concern yourself with. Don't include JAR files in the classpath that aren't being used. Don't include a bunch of code in your project JAR file that isn't being used. I highly doubt you'd be creating an application anywhere near the size required to impact the performance of the JVM.

Erick Robertson
Yup, there are very few times when jar size matters. It probably matters more when distributing a desktop app, as no one wants a 500MB download for a simple program. For server side apps, it would take a lot of "work" to be so big that it mattered...
bwawok
I completely agree with this, and my experience has been very similar. The usual place where the performance is hurt long before class size is in the algorithms, or if you have one very large class.
aperkins
Biggest culprits of jar bloat are enterprise / web applications, especially when built with Maven. So many dependencies and dependencies of dependencies get dragged in that it is not uncommon for a modest sized app to exceed 50Mb of jar files.
locka