Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable Object Statistics in JFR?

Tags:

java

jfr

I'm testing my Java code with filghtrecorder, all other data sees good(they shows sth.), but the "Memory -> Object Statistics" is empty.

Using JDK 1.8.0_161

Here is the parameter I used.

java -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:StartFlightRecording=dumponexit=true,filename=4.jfr,settings=default -jar myapp.jar

I tried change the settings to "settings=profile", but not help. (I don't know the different)

I'm wondering why it's not enable by default, or it's enabled but none of the object worth to record ?

like image 245
Zhang Yunlu Avatar asked Dec 13 '22 12:12

Zhang Yunlu


1 Answers

As you might be able to see in the JMC UI, it's the 'Object Count' event that is needed for that page. Make your own settings version, for example by copying the JDK/jre/lib/jfr/profile.jfc file and changing enabled to true in this section.

      <setting name="enabled" control="heap-statistics-enabled">false</setting>
      <setting name="period">everyChunk</setting>
    </event>

You can also use the JMC UI to create a new settings file, click on the Template Manager button in the Start Flight Recording wizard.

Either save the new file in JDK/jre/lib/jfr/ and then you can just use settings=mynewsettings in the commandline, or save it somewhere else and use settings=<fullpathtomynewsettingsfile>.

like image 105
Klara Avatar answered Dec 29 '22 18:12

Klara