- Java Open JDK and JRE installed on your machine Download OpenJDK
- Java Mission Control tool and be able to run it Download Java Mission Control
- Maven (>3)
- IDE of your choice
- JFR is part of JDK it produces detailed recordings about the HotSpot JVM, and the application it is running.
- It is an event recorder built into the Java virtual machine, it can be thought of as the software equivalent of a Data Flight Recorder (Black Box) in a commercial aircraft.
- Recorded events can be analyzed offline using the Java Mission Control tool.
- Recorded data includes profiling of methods, locks and allocations, as well as garbage collection statistics, optimization decisions, event latencies and more.
- In 2018 Java Flight Recorder was open sourced and released as part of OpenJDK 11, at later date it was backported into OpenJDK 8 from update 262.
- by adding JVM options to your java process
- by execution of
jcmd
instruction to your JVM process
- JDK Mission Control is an open source tools suite for the Java virtual machine.
- The tools help to find problems in, and optimizing, programs running on the JVM in production.
- Support OpenJDK from version 8 from update 262.
- connect to the running JVM process via JMX and do current quick analysis of CPU, Memory, process spec, GC cycles. This looks similar to Visual VM
- open Flight recorder file generated by the JFR process
- use JMC command to start flight recorder on given JVM process (Instruct JVM to start/stop JFR process).
- use JMC plugins
- on Open JDK8 (from update 262)
-XX:StartFlightRecording=settings=default,dumponexit=true,disk=true,maxsize=1MB,filename=testFlightRecord.jfr
This will start continuous recording of JFR events, with max size ever held of 1 MB it will output these recordings to testFlightRecord.jfr
file upon exit, or upon receive of DUMP instruction from jcmd
for example: jcmd <PID> JFR.dump name=1
setting=default
will start JFR with default config profile, there are two profiles available (one can add more or modify existing ones) located in jdk-11.0.8.10-hotspot\lib\jfr
- on Open JDK11 (the same command)
-XX:StartFlightRecording=settings=default,dumponexit=true,disk=true,maxsize=1MB,filename=testFlightRecord.jfr
$ jcmd <PID> JFR.start duration=10h filename=myrecording.jfr
or
$ jcmd <PID> JFR.stop
other commands:
JFR.configure
JFR.stop
JFR.start
JFR.dump
JFR.check
- Intellij has build in
Run with profiler
- Java Mission Control(JMC) can start JFR recording (it is using
jcmd
in the background)
to read data use Java Mission Control tool. Open it and point to the .jfr file.
from Java 14 streaming of the JFR events is available... JEP 349 Get a stream of high-volume data points about your running app. by Ben Evans
For further reference, please consider the following sections: