Amir Afghani
Amir Afghani

Reputation: 38541

Is there any way to monitor the compiled code cache in Java?

OK - I know I can run my java process like this :

java -XX:+PrintCompilation <FooProgram>

and I can see output like:

c:\>java -XX:+PrintCompilation -jar c:\FooProgram.jar
  1       java.lang.String::charAt (33 bytes)
  2       java.lang.Math::max (11 bytes)
  1%      java.util.jar.JarFile::hasClassPathAttribute @ 78 (197 bytes)
  3       java.lang.String::hashCode (60 bytes)
  4       java.lang.String::indexOf (151 bytes)
  5       java.util.Properties$LineReader::readLine (452 bytes)
  6       java.lang.Object::<init> (1 bytes)
  7       java.lang.String::indexOf (166 bytes)
  8       java.lang.String::equals (88 bytes)

to give me an idea of what methods are compiled, uncompiled, marked as zombies, etc. Is there anyway to monitor the usage of the code cache where these methods get compiled into? I see a message when the compiler code cache is full saying something like: "I'm full, no more compilations for you...", but it would seem as though something like this is a lagging indicator that we have a problem. I know how to print the max size of the code cache, what I'm looking for really is a way to see how its being filled up over time.

Upvotes: 6

Views: 7469

Answers (3)

ZZ 5
ZZ 5

Reputation: 1964

Since Java 8 you can use -XX:+PrintCodeCache more details can be found in this paper

Upvotes: 2

Kirk
Kirk

Reputation: 749

Old question but... I'll answer anyways... I have build a VisualVM plugin that will monitor stats about the code cache. It has been included in the open source version plug-in repository. Alternatively you can down load it and the source from java.net.

Oops, forgot link... https://java.net/projects/memorypoolview/

Upvotes: 2

Kees Jan Koster
Kees Jan Koster

Reputation: 26

JConsole will tell you. You can also install Java-monitor in your app server and look at the code cache in the "see all measurements" page for a host. http://java-monitor.com

Upvotes: 1

Related Questions