IntelliJ IDEA 2020.1 Help

Java Flight Recorder

Java Flight Recorder (JFR) is a monitoring tool that collects information about the events (pieces of data) in a particular instant of time in a Java Virtual Machine during the execution of an application.

Enable JFR for Oracle JDK 8 or later

Java Flight Recorder works on Oracle JDK builds starting from version 8 (providing that you have enabled commercial features) and on any JDK build starting from version 11.

To enable commercial features:

  1. From the main menu, select Run | Edit Configurations and from the list on the left, select the run configuration that you want to analyze with JFR.

  2. On the Configuration tab, expand the Environment section.

  3. To the VM options field, add the following line: -XX:+UnlockCommercialFeatures.

  4. Apply the changes and close the dialog.

Enabling JFR

JFR configurations

There are two pre-installed configurations: Default and Profile. The Default configuration has low overhead (about 1%). That's why it works well for continuous profiling. The Profile configuration has overhead about 2% and can be used for more detailed application profiling.

These configurations cover most use cases. However, you can create and upload your own settings by means of Java Mission Control.

Create a new JFR configuration

  1. Run Java Mission Control that you can find in JAVA_HOME/bin/jmc or download from builds.shipilev.net.

  2. From the Java Mission Control main menu, select Window | Flight Recording Template Manager.

  3. Click Import Files on the panel on the right and select one of the pre-installed configurations in the .jfc format:

    • For Java 10 and earlier: JAVA_HOME/jre/lib/jfr/

    • For Java 11 and later: JAVA_HOME/Contents/Home/lib/jfr/

  4. Select Edit | Advanced, change the necessary settings, and click OK.

  5. In the Flight Recording Template Manager dialog, click Export File.

  6. Specify another name for the new settings file and change its location if necessary. Click Save.

For more information on how to configure custom settings, refer to Controlling Recording Data by Using Templates.

Load the custom configuration to the IDE

  1. In the Settings/Preferences dialog Ctrl+Alt+S, select Build, Execution, Deployment | Java Profiler.

  2. Select the Java Flight Recorder profiling configuration to which you want to load your custom settings or create a new configuration by clicking the Add button.

  3. In the Profiling Settings area, select the Custom settings file option and click the Browse button.

  4. Specify the path to the custom settings file and click Open.

  5. Apply the changes and close the Settings/Preferences dialog.

Uploading custom settings to JFR

Profile your application with JFR

Use any of the following options to analyze your application:

  • Click Profiler on the toolbar (or click the the Run button icon in the gutter) and select Run 'run configuration name' with 'profiler configuration name':

    run with profiler

  • From the main menu, select Run | Run with Profiler and then select the necessary configuration (Run 'run configuration name' with 'configuration name').

When the profiling data is ready, you will see a confirmation popup together with the Profiler tool window bar. Click this bar to open the Profiler tool window or go to View | Tool Windows | Profiler if you don't use tool window bars.

Profiler popup informing that the data is ready
Last modified: 29 June 2020