How to use Oracle JDK Java Flight Recorder

Solution Verified - Updated -


  • Linux
  • Windows
  • OpenJDK/Oracle JDK (1.7.0_40 and up)
  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 7.x
    • 6.x
    • 5.2


  • How to use Oracle JDK Java Flight Recorder ?
  • Heap dump can't be provided because it contains sensitive information.
  • Heap dump from a production system can't be provided due to application performance impact.
  • Using instructions in, able to connect to a remote EAP6 instance using Java Mission Control (Oracle JDK 7u 72) . However, when tried to invoke JMC flight recorder, getting following message:
Commercial features are not enabled. To enable this, you need to use Java 7u4 or later JVM started with  -XX:+UnlockCommercialFeatures (To enable Flight Recorder, also add -XX:+FlightRecorder)


Disclaimer: Links contained herein to an external website(s) are provided for convenience only. Red Hat has not reviewed the links and is not responsible for the content or its availability. The inclusion of any link to an external website does not imply endorsement by Red Hat of the website or their entities, products or services. You agree that Red Hat is not responsible or liable for any loss or expenses that may result due to your use of (or reliance on) the external site or content.

Java flight recorder is a diagnostic and profiling tool for a running Java application. Below are described the usage of JFR on JDK 8 and JDK 11, then the recording of the data, and finally the analysis of the data:

JDK 8 (i.e. Prior to JDK 11)

To use Oracle JDK's Java Flight Recorder (JFR) it is necessary to run JBoss EAP with the following options:

-XX:+UnlockCommercialFeatures -XX:+FlightRecorder

These can be used with JAVA_OPTS on the shell, or editing

  • EAP 7/6
    • Standalone mode - $JBOSS_HOME/bin/standalone.conf on Linux or $JBOSS_HOME/bin/standalone.conf.bat on Windows.
    • Domain mode - $JBOSS_HOME/domain/configuration/domain.xml or $JBOSS_HOME/domain/configuration/host*.xml depending on where the JVM parameters are set
  • EAP 5.2+ $JBOSS_HOME/bin/run.conf - (Java 7 only supported from EAP 5.2.0)

JDK 11

One does not need the flags UnlockCommercialFeatures and FlightRecorder. The diagnostic tool, jcmd, will detect the process and it will have those flags enabled by default.

JFR commands

Recording data

Once the process starts (for example JBoss EAP), use the diagnostic tool to record the data (jcmd). jcmd is the application can start, check, dump and stop JFR.

To verify if the recording is available, use jcmd PID help, as in:

$ jcmd PID help
The following commands are available:
JFR.stop <--------------------------------------------------- stop
JFR.start  <-------------------------------------------------- start
JFR.dump  <-------------------------------------------------- dump
JFR.check  <-------------------------------------------------- check

Then, it is possible to use jcmd commands to execute the recording functions below:

Command Usage
$JAVA_HOME/bin/jcmd $JBOSS_PID JFR.start Starts JFR recording. It returns the recording number, which is used to dump the results to disk
$JAVA_HOME/bin/jcmd $JBOSS_PID JFR.check Lists the number of recordings running
$JAVA_HOME/bin/jcmd $JBOSS_PID JFR.dump recording=<recording_number> filename=<path/file> Dumps the JFR recording to disk
$JAVA_HOME/bin/jcmd $JBOSS_PID JFR.stop recording=<recording_number> Stops the specified JFR recording. This should be done after dumping and not prior.
$JAVA_HOME/bin/jcmd $JBOSS_PID help and any of the commands above can be used to list the available options for each command.

To limit the duration of the recording, to for 4 hours for example, use run:

$JAVA_HOME/bin/jcmd $JBOSS_PID JFR.start duration=4h

A JFR recording should occur when the system starts displaying the problematic behaviour on a production environment. On a development or testing environment, recording can start as soon as JBoss comes up and stop after the testing is done.

Note that JFR should be running as the same user the EAP service is running under. For instance, running EAP as the LOCAL SYSTEM account and JFR as the currently logged in user will result in an "Insufficient Privileges" error. You can use the PsExec Tool from Microsoft to escalate to the proper user.

More information can be found Java Flight Recorder and Oracle Java Components page.

JFR overhead

JFR will have an overhead, which differs from application to application.

Visualizing Data

On OpenJDK 8/ Oracle JDK 8 one can use Java Mission Control to analyse the data from the jfr file, as in:

In OpenJDK 11, the JFR is open source and available in the OpenJDK11/bin folder. However, JMC is not part of the JDK package anymore one can download it at JDK Java Net and project page Mission Control.

alt text


This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.


This is a good intro to jcmd, assuming the process is running under your id.

If it is a service, jcmd will not work in any way. Could someone address how to use jcmd with a service?

Try using psexec. To take a heap dump, the following works:

psexec -s jcmd $JBOSS_PID GC.heap_dump -all=true c:\dumps\dump.hprof