0

I'm starting Java Flight Recorder with the following command.

jcmd $PID JFR.start duration=2h filename=my_record.jfr dumponexit=true settings=profile

It's recording the first 2 hours after started.

For example, if it started at 1:00, it records from 1:00 to 3:00, even if I dump at 9:00.

I need to get the recordings from the last 2 hours, not from the first ones.

For example, if it started at 1:00 and dumped at 9:00, I need to get the recordings from 7:00 to 9:00.

What should I do?

hbelmiro
  • 987
  • 11
  • 31
  • This isn't a question about Java; it is a question about how to use a program that happens to be written in java. You need to read that program's documentation. – FredK Mar 02 '16 at 18:35
  • 2
    @FredK "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)" (http://docs.oracle.com/javacomponents/jmc-5-5/jfr-runtime-guide/about.htm#sthref7). It is about Java. – hbelmiro Mar 02 '16 at 18:38
  • You should be able to use JMC to dump a particular interval of the recording. Connect to your jvm using the JVM Browser, expand the Flight Recorder nose under your jvm and right click the recording you want, choose Dump... in the menu. I'm interested to hear if this works for you or not. – Klara Mar 09 '16 at 15:41

1 Answers1

3

You can control how far back to keep data, in time or in bytes, with the parameters maxage and maxsize. For example,

jcmd <pid> JFR.start maxage=2h filename=my_recording.jfr dumponexit=true settings=profile

or from command line

java -XX:+UnlockCommercialFeatures 
-XX:StartFlightRecording=maxage=2h,filename=my_recording.jfr,
dumponexit=true,settings=profile …

The dumponexit parameter, I think, only work with jcmd if you have JDK 8u40 or later

Kire Haglin
  • 6,569
  • 22
  • 27