Is there a way to control the compiled code cache in Java?

OK - I know that I can start my Java process as follows:

java -XX:+PrintCompilation <FooProgram> 

and I see the output, for example:

 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 ​​which methods are compiled, not compiled, tagged as zombies, etc. Is it even necessary to track the use of the code cache into which these methods are collected? I see a message when the compiler’s cache code is full, saying something like: "I'm full, there are no more compilations for you ...", but it would seem that something like this is an indicator of the lag that we have. I know how to print the maximum size of the code cache, what I'm looking for is really a way to see how it populates over time.

+4
source share
3 answers

JConsole will tell you. You can also install the Java monitor on your application server and see the cache code on the View All Dimensions page for the host. http://java-monitor.com

+1
source

An old question, but ... I will answer anyway ... I created a VisualVM plugin that will track statistics about the code cache. It has been included in the open source plugin repository. Alternatively, you can download it and the source from java.net.

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

+2
source

Starting with Java 8, you can use -XX:+PrintCodeCache more can be found in this article

0
source

Source: https://habr.com/ru/post/1302935/


All Articles