When the code cache fills up, the JVM will (usually) spit out a warning to that effect:
Java HotSpot(TM) 64-Bit Server VM warning: CodeCache is full.
Compiler has been disabled.
Java HotSpot(TM) 64-Bit Server VM warning: Try increasing the
code cache size using -XX:ReservedCodeCacheSize=
It is sometimes easy to miss this message, and some versions of Java 7 do not print it cor-
rectly when tiered compilation is enabled. Another way to determine if the compiler has
ceased to compile code is to follow the output of the compilation log discussed later in this
Table 4-6 lists the default value of the code cache for various platforms.
Table 4-6. Default code cache based on platform
Default code cache size
32-bit client, Java 8
32-bit server with tiered compilation, Java 8 240 MB
64-bit server with tiered compilation, Java 8 240 MB
32-bit client, Java 7
32-bit server, Java 7
64-bit server, Java 7
64-bit server with tiered compilation, Java 7 96 MB
In Java 7, the default size for tiered compilation is often insufficient, and it is often necessary
to increase the code cache size. Large programs that use the client compiler may also need to
increase the code cache size.
There really isn't a good mechanism to figure out how much code cache a particular applica-
tion needs. Hence, when you need to increase the code cache size, it is sort of a hit-and-miss
operation; a typical option is to simply double or quadruple the default.