Java Exceptions counter on JVM HotSpot

I believe there are free tools to do it, but even making your own tool is easy. JVMTI will help. Here is a simple JVMTI agent I made to trace all exceptions: #include <jni.h> #include <jvmti.h> #include <string.h> #include <stdio.h> void JNICALL ExceptionCallback(jvmtiEnv* jvmti, JNIEnv* env, jthread thread, jmethodID method, jlocation location, jobject exception, jmethodID … Read more

Analyzing gc logs

Unfortunately PrintGCApplicationStoppedTime is misleading name for this JVM option. In fact it prints the time spent inside safepoints. Safepoint pauses occur not only due to Garbage Collection, but for many other reasons: Deoptimization Biased lock revocation Thread dump Heap inspection Class redifinition etc. (see the list) Safepoints may happen periodically even without a requested VM … Read more

How does the JVM decided to JIT-compile a method (categorize a method as “hot”)?

HotSpot compilation policy is rather complex, especially for Tiered Compilation, which is on by default in Java 8. It’s neither a number of executions, nor a matter of CompileThreshold parameter. The best explanation (apparently, the only reasonable explanation) can be found in HotSpot sources, see advancedThresholdPolicy.hpp. I’ll summarize the main points of this advanced compilation … Read more