Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to record allocations with JFR on command line?

Tags:

profiling

jmc

jfr

I have a profile I've created with Java Mission Control that has allocation profiling enabled. When I used it from the JMC UI to record, everything works fine and I get the results.

However, after exporting the settings and trying to record with JFR on command line, I don't get the allocations recorded, even though I get other profiling information.

I run the recording with the following settings: JAVA_OPTS="$JAVA_OPTS -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:FlightRecorderOptions=defaultrecording=true,settings='<path_to_settings>/settings.jfc',dumponexit=true,dumponexitpath=<output>" java -jar stuff

When loading the recording in JMC and checking the memory part, I see message Event type 'Allocation in new TLAB' is not enabled in this recording.

The settings file is here: https://gist.github.com/jmiettinen/1976f9bbe156ecb5e232 and it has the relevant settings java/object_alloc_in_new_TLAB and java/object_alloc_outside_TLABenabled.

Am I missing something here? I am running 1.8.0_66 and would want to have a continuous recording from the start of the application until it is stopped.

like image 832
jmiettin Avatar asked Jan 19 '16 16:01

jmiettin


People also ask

How does JFR work?

JFR collects data from the JVM (through internal APIs) and from the Java application (through the JFR APIs). This data is stored in small thread-local buffers that are flushed to a global in-memory buffer. Data in the global in-memory buffer is then written to disk.

What is JFR profiling?

Java Flight Recorder (JFR) is a tool for collecting, diagnosing, and profiling data about a running Java application. It is integrated into the Java Virtual Machine (JVM) and causes almost no performance overhead, so it can be used even in heavily loaded production environments.


2 Answers

Verified with @jmiettin at Jfokus that these flags do the trick:

These options seem to work for me if you want to have a continuous recording with the special settings and get it to dump the data on exit: -XX:FlightRecorderOptions=dumponexit=true,dumponexitpath=rec.jfr -XX:StartFlightRecording=defaultrecording=true,settings=d:/tmp/wop.jfc

Difference is to put defaultrecording and settings parameters after the -XX:StartFlightRecording flag instead.

like image 173
Klara Avatar answered Sep 29 '22 11:09

Klara


Which version of the JDK are you running?

There is a bug, fixed in 7u76 and 8u20, where the settings parameter is not respected if defaultrecording=true.

like image 44
Kire Haglin Avatar answered Sep 29 '22 09:09

Kire Haglin