Getting started with JFR

Let's get started with a simple HelloWorld example, as follows:

class HelloWorld { 
    public static void main(String[] args) { 
        System.out.println("Hello World - This is being recorded"); 
    } 
} 

To start flight recording for the preceding application, execute the following command on your console:

  > java -XX:StartFlightRecording,filename=hello.jfr 
     HelloWorld  

The first line instructs the Java Runtime to start flight recording for your HelloWorld application and save it to the HelloWorldRecording.jfr file.

There are three parts to the previous command, as follows:

  • Starting JFR with the -XX:StartFlightRecording JVM option
  • Specifying the target file to save the recording to hello.jfr
  • Specifying the application to run HelloWorld

Let's start MC to view the profiling data stored in hello.jfr. Use the jmc.exe file to start JMC. You'll see a window similar to the following screenshot:

Click on the Click here to start using JDK Mission Control option at the bottom. Using the File | Open menu options, open the hello.jfr file you previously created. Here's what it displays at the Automated Analysis Results landing page:

Processes are not the only category on which MC analyzes your application. Depending on your application and how it is profiled, additional categories are included (you can see a few of them in the preceding screenshot).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.9.147