javajfr

How to run javaFlightRecorder on jar file


I have a Compiled java program as jar file. Can I run jfr on jar files? how?

Can I specify what I want to benchmark?


Solution

  • Assuming you are running JDK 11, or later, and want the file dump when the program ends:

    $ java -XX:StartFlightRecording:filename=dump.jfr -jar benchmark.jar
    

    You can then open up the file in JMC to see information about garbage collection, allocation, hot methods etc.