Usage:
This flag allows to set an initial code cache size in bytes.-XX:InitialCodeCacheSize=value, where value is the size of the initial code cache.
Since:
Starting from JDK 6.
Examples:
This will instruct JVM to use 512 Megabyte as initial code cache:
-XX:InitialCodeCacheSize=512M
Description:
We shall explain “Code cache” before talking about the flag “InitialCodeCacheSize”. 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.
JVM introduced many flags that operates on the code cache. Such as the flag “InitialCodeCacheSize” which set an initial code cache size.
You can also see the initial code cache size of a running java program using jinfo.
Without using the flag:
The default size in the Linux environment is 2555904 bytes (2.43 Megabyte)
Using the flag to set initial code cache to 512 Megabyte:
Warning: If you set an initial code cache above the default “ReservedCodeCacheSize”, which is 32M or 48M then you will need to add it as an argument.
java -XX:InitialCodeCacheSize=512M -XX:ReservedCodeCacheSize=512M MainClass
You can also specify a data unit such as “k” or “K” for kilobytes, “m” or “M” for Megabytes and “g” or “G” for Gigabytes.
- For using 512 Kilobytes: -XX:InitialCodeCacheSize=512k
- For using 128 Megabytes: -XX:InitialCodeCacheSize=128m
- For using 12 Gigabytes: -XX:InitialCodeCacheSize=12g
Default Value:
The default value varies, it might be 160Kb, 500Kb, 2048K ... depending on the Operating System.
Arguments related:
ReservedCodeCacheSize, UseCodeCacheFlushing
Related Posts:
Edit your Comment