Starting a JFR Recording
There are various ways to start a flight recording. For this exercise, we will use the Flight Recording Wizard built into JDK Mission Control.
First switch to the Java perspective. Note that there is an empty project named Recordings. Next start the DoNothing program by right clicking on the DoNothing.launch file in the Launchers folder of the 01_DoNothing project, as show below.
Note: There are “Auto Record” versions of most launchers, which will launch the application and automatically create a recording in the autorecordings folder in the tutorial root. This is since, in certain environments (slow machines running a virtualized Windows for example), the highly loaded JVM that JMC is trying to communicate with will take so long to getting around to communicate with JMC that it simply is no fun to wait. If that is the case, simply run the “Auto” launchers. Or,
you know, if you’re lazy. I will not judge. Just try doing this first exercise without Auto, as it is about doing recordings from JMC.
Java Mission Control Perspective
Switch to the Mission Control perspective and select the newly discovered JVM running the DoNothing class in the JVM Browser. Select Start Flight Recording… from the context menu. The Flight Recording Wizard will open. Click Browse to find a suitable location (e.g. the Recordings project) and filename for storing the recording. Don’t forget to name the recording so that it can be recognized by others connecting to the JVM, and so that the purpose of the recording can be better remembered. The name will be used when listing the ongoing recordings for a JVM, and will also be recorded into the recording itself.
Next select the template you want to use when recording. The template describes the configuration to use for the different event types. Select the Profiling – on Server template, and hit Finish to start the recording.
The progress of the recording can be seen in the JVM Browser, when the Flight Recorder node is expanded. It can also be seen in the status bar.
Use the minute to contemplate intriguing suggestions for how to improve Mission Control (don’t forget to e-mail them to email@example.com), get a coffee, or read ahead in the tutorial.
Once the recording is done, it will be downloaded to your Mission Control client, and opened. Switch to the JDK Mission Control perspective.
You should be looking at the automated analysis of the recording.
Start Java Flight Recorder
This exercise is just to familiarize you with one of the ways to create a flight recording. This will be a rather boring recording, in terms of results from the automated analysis, so don’t mind the results of this analysis.
Since the recording was done on a process not doing any actual work, the auto- analysis didn’t find anything other than that I should probably run less stuff on my laptop:
- I am starting to run out of physical memory. I am guessing MS Word ate a good portion of it. ;)
- I have a lot of other processes running aside from the JVM. Since this is my laptop, and not a dedicated server, I am not surprised.
The Outline view shows the various pages in the JDK Flight Recorder user interface. Select Java Application.
Here we get an overview of commonly interesting properties of the recording. This process didn’t do much, but we can see that what little it did was spent transferring data.
This exercise was mostly to describe how to make a Java Flight Recorder recording, and basic navigation in the user interface. Once you are done with the recording, remember to shut down the DoNothing application.
- Either go to the Java perspective and hit enter in the Console view,
- … or go the Debug perspective, find the LoadAndDeadlock process and click the Terminate button
Note: Also, remember to close the recording editor window when you are done with a recording. Recordings contain a lot of information and can consequently use a lot of memory.
Here are some additional videos and articles of mine (Cameron McKenzie) about Java Mission Control and Java Flight Recorder:
- Quick Introduction to Java Mission Control
- Java Mission Control 8 Eclipse plugin Install
- Fix Java memory leaks without costly JVM heap dumps
- The performance cost of autoboxing Java primitive types
- How to start Java's JVM Flight Recorder 3 easy ways
- Performance Problems with Synchronized Methods