Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a performance difference between Javac debug on and off?

If I switch on the generating of debug info with Javac then the class files are 20-25% larger. Has this any performance effects on running the Java program? If yes on which conditions and how many. I expect a little impact on loading the classes because the files are larger but this should be minimal.

like image 512
Horcrux7 Avatar asked Oct 20 '08 10:10

Horcrux7


People also ask

What is run debug in Java?

Debugging is the routine process of locating and removing bugs, errors or abnormalities from programs. It's a must have skill for any Java developer because it helps to find subtle bug that are not visible during code reviews or that only happens when a specific condition occurs.

Is debug enabled Java?

Click Java > JVM Settings tab. Under Debug Java Settings, select the Enable Debug checkbox.


1 Answers

In any language, debugging information is meta information. It by its nature increases the size of the object files, thus increasing load time. During execution outside a debugger, this information is actually completely ignored. As outlined (although not clearly) in the JVM spec the debug information is stored outside the bytecode stream. This means that at execution time there is no difference in the class file. If you want to be sure though, try it out :-).

Ps. Often for debugging there is value in turning off optimization. That does have a performance impact.

like image 162
Paul de Vrieze Avatar answered Sep 21 '22 18:09

Paul de Vrieze