Java Flight Recorder (JFR) is
a tool for collecting diagnostic and profiling data about a running
Java application. In this post, I am going to explain how create
detailed profile including heap and class statistics of your java
application. As you may already know, JFR will be executed via JCMD
Utility which sends diagnostic command requests to the JVM.
jcmd.exe comes by default with JDK installation which you can find in $JAVA_HOME\bin directory. What JFR does is collecting low level and detailed run time information of java applications that runs on top of JVM. JFR comes with a default profiler which has generic recording templates that you can find in below directory of the JDK installation.
$JAVA_HOME\jre\lib\jfr
Using below in command prompt, you can collect general profiling information which used default setting.
jcmd.exe ProcessID JFR.start duration=600s filename=FileName.jfr
Above command will use "default.jfc" which is written to collect below run-time statistics.
Now let's see how to conduct a detailed profiling by changing these settings. To do this, open the recording that first collected using default settings. This will open up "Oracle java Mission Control" UI. Now select "Window -> Flight Recording Template Manager" from the menu.
Select "Default" and then click "Duplicate". Then select newly created template and click "Edit". You can then make changes highlighted in below image and click OK. This will add a new template "DetailedProfiling" which we can now use for detailed profiling.
Now open the command prompt and execute below command.
jcmd.exe ProcessID JFR.start settings=C:\Java\jdk1.7.0_80\jre\lib\jfr\DetailedProfiling.jfc duration=600s filename=FileName.jfr
This will now start the recording and once the profiling duration is completed, you can open it and see statistics related to Memory, Code, System, etc which will really be useful in finding memory leakages and performance improvements of java applications.
jcmd.exe comes by default with JDK installation which you can find in $JAVA_HOME\bin directory. What JFR does is collecting low level and detailed run time information of java applications that runs on top of JVM. JFR comes with a default profiler which has generic recording templates that you can find in below directory of the JDK installation.
$JAVA_HOME\jre\lib\jfr
Using below in command prompt, you can collect general profiling information which used default setting.
jcmd.exe ProcessID JFR.start duration=600s filename=FileName.jfr
Above command will use "default.jfc" which is written to collect below run-time statistics.
Now let's see how to conduct a detailed profiling by changing these settings. To do this, open the recording that first collected using default settings. This will open up "Oracle java Mission Control" UI. Now select "Window -> Flight Recording Template Manager" from the menu.
Select "Default" and then click "Duplicate". Then select newly created template and click "Edit". You can then make changes highlighted in below image and click OK. This will add a new template "DetailedProfiling" which we can now use for detailed profiling.
Now open the command prompt and execute below command.
jcmd.exe ProcessID JFR.start settings=C:\Java\jdk1.7.0_80\jre\lib\jfr\DetailedProfiling.jfc duration=600s filename=FileName.jfr
This will now start the recording and once the profiling duration is completed, you can open it and see statistics related to Memory, Code, System, etc which will really be useful in finding memory leakages and performance improvements of java applications.