Support Article
High JVM codecache utilization reported in production and in UAT
SA-12272
Summary
High JVM code cache utilization reported in production and in UAT environments. Introscope Wily monitoring system repots 97% code cache utilization.
No error messages present in the logs.
JVM Version:
Java HotSpot(TM) 64-Bit Server VM
Java version 1.6.0_37
java.vm.version 20.12-b01
Application Server:
WebSphere Platform 7.0.0.27
Host Operating System:
SunOS, version 5.10
Error Messages
Not Applicable
Steps to Reproduce
There is no specific use case to reproduce this issue.
Root Cause
The code cache is a memory area separate from the JVM heap that contains all the JVM bytecode for methods compiled into native code. On 64 bit VMs the reserved cache size is 48 MB. Default code cache size could be too small for complex applications and can be set higher if the application requires it. If the code cache overflows, default behavior is to switch to interpreted-only mode which increases the CPU usage and slows down the application.
Resolution
To detect code cache size related issues check for the presence of the following messages in the application server logs:
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=
Java HotSpot(TM) 64-Bit Server VM warning: Try increasing the code cache size using -XX:ReservedCodeCacheSize=
To verify the code cache usage, use the JConsole tool provided with the JDK and then switch to the 'Memory' tab to find out the code cache size.
In case of code cache overflow, increase the code cache size and enable the UseCodeCacheFlushing option to allow the JVM to flush unused classes from JIT Hotspot code cache if cache fills up.
In order to do so add the following JVM options to the startup script of your application server.
In order to do so add the following JVM options to the startup script of your application server.
- -XX:ReservedCodeCacheSize=128m
This option tells the JVM to allocate 128 MBytes for the code cache
- -XX:+UseCodeCacheFlushing
This option tells the JVM to clear some of the compiled code from the cache but continue to use it
After after applying these changes check that messages about the code cache being exhausted are no more present in the logs.
Published July 23, 2015 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.