2

I'm trying to analyze a large Flight Recorder file (1.5 GB) that I created previously. When executing the jfr print command, the tool runs into an OutOfMemoryError:

$ jfr print --events "jdk.CPULoad" <file>

jfr print: unexpected internal error, Java heap space
java.lang.OutOfMemoryError: Java heap space
    at jdk.jfr/jdk.jfr.consumer.ParserFactory$CompositeParser.parse(ParserFactory.java:283)
    at jdk.jfr/jdk.jfr.consumer.ParserFactory$ArrayParser.parse(ParserFactory.java:268)
    at jdk.jfr/jdk.jfr.consumer.ParserFactory$CompositeParser.parse(ParserFactory.java:285)
    at jdk.jfr/jdk.jfr.consumer.ChunkParser.fillConstantPools(ChunkParser.java:141)
    at jdk.jfr/jdk.jfr.consumer.ChunkParser.<init>(ChunkParser.java:71)
    at jdk.jfr/jdk.jfr.consumer.ChunkParser.<init>(ChunkParser.java:56)
    at jdk.jfr/jdk.jfr.consumer.RecordingFile.findNext(RecordingFile.java:253)
    at jdk.jfr/jdk.jfr.consumer.RecordingFile.<init>(RecordingFile.java:108)
    at jdk.jfr/jdk.jfr.internal.tool.EventPrintWriter.print(EventPrintWriter.java:71)
    at jdk.jfr/jdk.jfr.internal.tool.Print.execute(Print.java:165)
    at jdk.jfr/jdk.jfr.internal.tool.Main.main(Main.java:84)

Is there a way to increase the heap size (-Xmx) for the jfr tool itself? I haven't found a corresponding option in the documentation. Any help is appreciated :)

Markus
  • 1,649
  • 1
  • 22
  • 41
  • Did you try the disassemble and then print each chunks ? – Kris Oct 18 '21 at 12:57
  • Unfortunately, the file only consists of 1 chunk. When trying to disassemble it into pieces of max 250MB, I get:`File consists of 1 chunks. The recording will be split into 1 files` and the file stays at 1.5 GB – Markus Oct 18 '21 at 13:02
  • 1
    Try setting JAVA_TOOL_OPTIONS with a higher Xmx in the OS variables and run JFR. – Kris Oct 18 '21 at 13:04
  • Good to know it worked! – Kris Oct 18 '21 at 14:25

2 Answers2

2

As suggested by Kris, there is an environment variable that can be used: JAVA_TOOL_OPTIONS

In my case, the following did the trick:

export JAVA_TOOL_OPTIONS="-Xmx5G"
Markus
  • 1,649
  • 1
  • 22
  • 41
0

You can also pass JVM options by using the -J prefix, for example:

$ jfr -J-Xmx3048m print --events "jdk.CPULoad" <file> 

Normally the file size should not matter. Data comes in chunks, each about 10-15 MB, and memory is released when a new chunk begins, but it looks like everything is in one chunk, perhaps because it was emitted during a very short period, so the JVM didn't have a chance to rotate the file.

Future version of the JDK may allow filtering, i.e. extract all CPULoad events into a file. https://bugs.openjdk.java.net/browse/JDK-8269767

Kire Haglin
  • 6,569
  • 22
  • 27