Java Mission Control Heap Profile
Asked Answered
T

1

10

I am playing with the new Java Mission Control Profiler that is coming with the Java 7u40 and I cannot make it to profile allocation and collect object statistics. No matter what I do, I cannot see any statistics in the Memory -> Object Statistics window.

The following command starts the collection:

jcmd <pid> JFR.start duration=60s settings=profile filename=alloc-prof.jfr

The Java Mission Control documentation does not mention any specific options to enable object profiling. I have tried to create my own profile and set :

  <flag name="heap-statistics-enabled" label="Heap Statistics">true</flag>
  <flag name="allocation-profiling-enabled" label="Allocation Profiling">true</flag>

But still no Object Statistics are collected.

Tater answered 27/9, 2013 at 17:37 Comment(0)
G
11

Use the template manager that is available in Mission Control.

Go to Windows -> Template Manager and import the template and check Heap Statistics and Allocation Profiling, export it. Done!

If you want to edit the jfc-file manually, it can be good to know elements inside the control-element are not read by the JVM, i.e flag-element, They are used by JMC to modify the parameters outside the control element (the one with the control attribute)

A manual edit requires that you modify these:

set java/object_alloc_in_new_TLAB enabled to true

set java/object_alloc_outside_TLAB enabled to true

set vm/gc/detailed/object_count enabled to true

Note, there are two object count events, with object_count_after_gc you will increase GC times. If you pick the one above instead, you will get one additional GC per recording chunk (which is usually sufficient)

Georgena answered 27/9, 2013 at 21:52 Comment(5)
Thanks! I will try the Export option first.Antwanantwerp
@kire-haglin Thanks for the detailed response, very helpful! Is there more documentation on what exactly object_count and object_count_after_gc do and what the period everyChunk means? I.e., do both cause an additional GC and if so, why? And what is a "recording chunk"?Predigest
You can think of a recording chunk as a log file. With period="everyChunk" the event is written when the "log file" is rotated. This guarantees that you have at least one such event per recording file (which is made up of one or several recording chunks). Only object_count adds an additional GC.Georgena
This didn't work for me. I was able to check "Heap Statistics" and tried multiple times, but I still do not get an object count and JMC says "Object Count" is not enabled in this recording. Is there something else that needs to be done? Does the JVM need to be started with some parameters?Talion
Ok, I figured it out. It didn't work for me because I didn't let the flight recording go until the end of the time I set. I set the recording for 60 minutes and stopped it after a couple minutes. So I tried a recording for 5 minutes and let it complete on its own. Then the object stats showed up.Talion

© 2022 - 2024 — McMap. All rights reserved.