Appendix A. Summary of Tuning Flags

Table A-1. Flags to tune the just-in-time compiler
Flag What it doesWhen to use itSee also

-server

Chooses the server compiler.

For long-running applications that need fast performance.

Hot Spot Compilation

-client

Chooses the client compiler.

For applications where startup is the most important factor.

Hot Spot Compilation

-XX:+TieredCompilation

Uses tiered compilation (both client and server).

For applications where you want the best possible performance and have enough available native memory for the extra compiled code.

Hot Spot Compilation

-XX:ReservedCodeCacheSize=<MB>

Reserves space for code compiled by the JIT compiler

When you see a warning that you are out of code cache, and generally when using tiered compilation.

Tuning the Code Cache

-XX:InitialCodeCacheSize=<MB>

Allocates the initial space for code compiled by the JIT compiler.

If you need to preallocate the memory for the code cache, which is very uncommon.

Tuning the Code Cache

-XX:CompileThreshold=<N>

Sets the number of times a method or loop is executed before compiling it.

When using the server compiler, this can cause more methods to be compiled, and methods to be compiled sooner. The first case is sometimes an advantage if you aren’t using tiered compilation.

Compilation Thresholds

-XX:+PrintCompilation

Provides a log of operations by the JIT compiler.

When you suspect an important method isn’t being compiled, or are generally curious as to what the compiler is doing.

Inspecting the Compilation Process ...

Get Java Performance: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.