How to collect Java Flight Recorder (JFR) data for troubleshooting application performance

  • Updated

Java Flight Recorder (JFR) is a tool for helping debug many kinds of performance issues.  JFR captures a large set of JVM performance information into a flight recording file.  The recording can then be analyzed offline using Java Mission Control.

 

Note: JFR is not available on IBM JREs.  Please see - How to generate a YourKit session if using an IBM JRE.

 

OpenJDK 8u262 and 11+

JFR is available in OpenJDK 11+.  Additionally, it was back-ported to OpenJDK 8u262, so all recent OpenJDK 1.8 distributions should have JFR available.

We normally ask that you capture a profiling recording via modifying the settings property to settings=profile.

 
The contents should be recorded to a location that the file can be retrieved from and sent to Contrast Security for analysis.
The agent's logging level should be set to WARN or ERROR when capturing the profiling recording.  See agent.logger configuration at - Java Configuration for further details.
 
What settings=profile captures may vary from Java release to release.  The following are a few example configurations for starting a JFR:
# Record to file "recording.jfr", use the settings "profile"
-XX:StartFlightRecording=filename=recording.jfr,settings=profile

# Record to file "recording.jfr", record for 5mins before dumping results, use the settings "profile" -XX:StartFlightRecording=filename=recording.jfr,duration=300s,settings=profile
# Record to file "recording.jfr", delay starting recording for 30s, use the settings "profile" -XX:StartFlightRecording=filename=recording.jfr,delay=30s,settings=profile
 

Recording to disk manually using jcmd

The following example recording to disk and using jcmd requires a JDK install and access to the server/container running the application. For example:

-XX:StartFlightRecording=disk=true,name=recording-1,filename=/tmp/agent.jfr,maxage=15m,dumponexit=true,settings=profile

Then, log in to the application server and run jcmd to find the process ID.

Then, run jcmd <PID> JFR.dump filename=/recording.jfr to record the data.

 

See also:

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request