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

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.


Turning off debugging alone should not make a difference at all. But once you turn off debugging and turn on optimization, you should see a difference, as this makes some static optimizations at compile time. This way even your hot-spot optimized code gets faster at runtime.

But so far, the tradeoff between getting meaning full stack-traces or having some more user-performance, I always voted for the stack-traces. After all, users are willing to spend 1000$ each year to get a faster machine, but are not willing to spend 15 minutes to give you meaningful error messages to you to solve their problems.

After the years, I'm more willing to value my 15 minutes higher than the user's 1000$. :)


Please be aware that since JDK1.3 javac ignores any optimization flags, "compile-time optimization is unnecessary"