Search code examples
profilingjmcjfr

How to record allocations with JFR on command line?


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.


Solution

  • 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.