Usage:
The option “-XX:[+|-]UseCodeCacheFlushing” removes cold/old methods from the code cache.
Since:
Starting from JDK 6.
Syntax:
java -XX:[+|-]UseCodeCacheFlushing MainClass
Example:
- To enable flushing of the code cache before shutting down the compiler: java -XX:+ UseCodeCacheFlushing MainClass
- To disable flushing of the code cache before shutting down the compiler: java -XX:-UseCodeCacheFlushing MainClass
Description:
We shall explain “Code cache” before talking about the flag “UseCodeCacheFlushing”. Code cache is where the JVM stores bytecode compiled into native code. Each section of the executable native code is called a nmethod which they might be a complete or inlined Java method. The JIT is the biggest user of the code cache.
When running the JVM, it has a default value for code cache size. The following table display the default value for each code cache option:
As we can see in the table above, the JVM has a fixed size for code cache. Once the code cache is full, the JIT compiler stop which makes the JVM to stop compiling code and you will see on the terminal output a warning stating that the “Code Cache is Full”. This will result in a reduced performance. To fix this issue, you should only increase the initial, reserved Code Cache or the expansion size in the table above.
Luckily, JVM introduced the flag “UseCodeCacheFlushing” which enables/disables the flushing and removing of code before shutting down the compiler when the following conditions are met:
- The cache code is full
- The interval since the last flush is passed
- The pre-compiled code is old
Default Value:
This option is enabled by default.
Errors:
None.
Related Posts:

Edit your Comment