Visit Azul.com Support

Analyzing Your Application With JFR

Table of Contents
Need help?
Schedule a consultation with an Azul performance expert.
Contact Us

Java Flight Recorder (JFR) is a profiling and event collection framework built into the Java Virtual Machine (JVM). With JFR, you can collect detailed runtime information about various aspects of a Java application, such as method execution, memory allocation, garbage collection, and more. This information is valuable for performance analysis, troubleshooting, and optimization of Java applications.

Making a JFR Recording

At Application Startup

To enable recording from startup of an application, use the following command-line option:

 
-XX:StartFlightRecording=filename=rec.jfr,duration=60s,settings=profile
  • filename=/tmp/rec.jfr: The file that is used to store the recording.

  • duration=600s: Specifies the maximum duration for a flight recording. It determines how long the recording continues capturing events and metrics before automatically stopping. You can use this option to limit the duration of a recording to avoid capturing an excessive amount of data and to control the impact on the application’s performance.

  • settings=profile: By default, Flight Recorder uses the settings defined in <java_home>/lib/jfr/default.jfc which gives a good balance between data and performance. In the same directory, you can find a second configuration profile.jfc which records more events and is useful while profiling an application. You can also create a copy of one these files and create your own configuration, e.g. my-config.jfc.

Check JFR Command Line Options in the documentation of Azul Mission Control for all available options and more info.

From a Running Application

On the same host and userid as the Java process under analysis, run the following command to start a recording:

 
$ jcmd JVMID JFR.start filename=rec.jfr

Where JVMID is either the process ID or the classname assigned with the java process as shown when running jcmd without parameters.

To stop a recording, use:

 
$ jcmd JVMID JFR.stop name=1

To start a recording with more detailed metrics, use the following with extra options as explained above:

 
$ jcmd JVMID JFR.start filename=rec.jfr settings=profile

Analyzing a JFR Recording

JFR recordings are most easily viewed in Azul Mission Control, and you can connect to a running application from within Azul Mission Control to create a recording. More info is available in the Azul Mission Control documentation.