The -Xbatch flag disables background compilation of the JVM bytecode by
Hotspot. Normally when a method is first invoked, Hotspot runs the method
immediately in interpreted mode and later compiles it to native code in order to
speed up future invocations.
Enabling the -Xbatch flag prevents compilation from occurring on a background
thread. Instead the method is compiled in the calling thread, blocking it until
complete. Then the method is actually invoked.
-Xbatch is often used in conjunction with -Xcomp, which forces immediate
compilation of each method on first invocation.
This optimisation may be relevant in batch programs where the interactive
responsiveness of the program is unimportant, or not as important as in a UI
application, for example. In a batch program only the total time taken by the
entire program is important. Serializing the compilation of methods may reduce
this total time, because less synchronization across threads is required, though
this may be at the expense of making one or more method invocations slower.
However in modern JVM implementations the -Xbatch flag is unlikely to result in
any performance gain, and may even cause a loss of performance. Therefore most
applications, including batch-style programs, should avoid using the -Xbatch
-Xbatch is off by default, i.e. background compilation is enabled.
Arguments Related to -Xbatch:
TODO: link to -Xcomp, -Xint
If you have additional comments, interesting experiences or even point of disagreement with this JVM argument description, please leave a comment. Your
insights will help the entire 10+ million java developer community to develop
one standard source of documentation for all the JVM arguments.