How to analyze code cache usage

Code cache is a memory area separate from the JVM heap that contains all the JVM bytecode for a method compiled down to native code, each called an nmethod1. This is where the JIT compiled methods are kept.

Impact of the Code Cache being full is that JIT compilation is now off for the remainder of the JVM’s life. CPU utilisation & request service time would increase over long running VMs for code that could have been optimised. For a system that is over-committed on CPU resources the application throughput could decrease noticeably.

So how to measure your current usage of code cache?

Step 1 : Launch  VisualVm

VisualVm tool comes as a part of JDK and is a very useful tool for memory,CPU and threads analysis. Once launched it will detect all the JVM based application running in the system. Click on the one you want to analyze

 

 

Step 2 : Install Memory pool plugin

VisualVm does have a memory analysis tab but by default it does not contain any details about code cache. So we need to install a 3rd party plugin for that. You can download this plugin here : Memory pool plugin for VisualVm. I had downloaded b5 version.

Once downloaded, you can install the plugin by going to Tools > Plugins > Downloaded > Add Plugins

Step 3 : Go to memory pool section

Once installed, click on the Java process again and now you will see memory pools tab.  Inside that you will find a separate section for code cache at bottom right

 

Now you can analyze how your applications are consuming code cache. Please keep in mind if code cache limit is getting crossed, JIT compilation will get disabled which will lead to degradation of the performance of your applications

Uday Ogra

Connect with me at http://facebook.com/tendulkarogra and lets have some healthy discussion :)

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *