Java Flight Recorde (JFR) is, in a nutshell, a Java profiler. A module included in Java SE Advanced that requires a commercial license (for a fee) to be used in a production environment, but can be used free of charge during development.
JFR is built into the Java SE execution environment from Java7, It (apparently) efficiently records the data already collected in the Java runtime environment! It will also be included in the latest Java 9.
Well-known Java profilers other than JFR jvmmonitor, JProfiler, JProbe, a while ago, there is TPTP (Test & Performance Tools Platform) of Eclipse, but There is a charge, or development is stopped and it can no longer be used.
JFR suddenly crashes the machine when the application is running all the time! Or, this application has a bad response! It is a tool to use when you need to investigate memory leaks or improve the performance of your application.
The functions of JFR are as follows.
-** Profiling ** JFR continually stores large amounts of data about operating systems. This profiling information includes the following information and the like. --Java application information: exceptions, threads, file I / O, network I / O, etc. --JavaVM information: memory allocation, class loading, JIT, GC, method sampling --OS information: Memory and CPU usage information
-** Black Box Analysis ** JFR continuously stores information in a circular buffer, so if you access this information when an anomaly is detected, you can find out the cause.
To use JFR from Java commands, specify the following options.
-"-XX: + Unlock Commercial Features": Unlock commercial features -"-XX: + FlightRecorder": Enable JFR --"-XX: StartFlightRecording": Start recording JFR
How to run the MyApp application and immediately start recording for 60 seconds and save it to a file named recording.jfr
$ java -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:StartFlightRecording=duration=60s,filename=/tmp/recording.jfr MyApp
See below for the parameters of "-XX: Start Flight Recording".
[https://docs.oracle.com/cd/E22646_01/doc.40/b61441/optionxx.htm#BABIEFBA](https://docs.oracle.com/cd/E22646_01/doc.40/b61441/optionxx.htm#BABIEFBA)
## Used with jcmd command
The jcmd command is a command that allows you to profile a running Java process.
To use JFR from the jcmd command,
The "-XX: + UnlockCommercialFeatures" and "-XX: + FlightRecorder" options must be specified when starting the Java application.
How to start recording for 60 seconds in a running Java process with a process identifier of 5368 and save it to a file named recording.jfr
#### **`$ jcmd 5368 JFR.start duration=60s filename=/tmp/recording.jfr`**
It seems that Java 9 will make the JFR UI significantly different and easier to use. The JFR API will be supported to allow recorder control and custom event generation.
The performance of an application is greatly affected by how it is made, and I think that many of the factors that cause performance degradation are problems of how it is made (creator).
If you can use profiling tools to find and fix bottlenecks, You can dramatically improve the performance of your application!
Let's make effective use of profiling tools to develop better things.
JFR is available free of charge during ** development! ** **
Recommended Posts