Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Mission Control Heap Profile

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.

like image 597
Aleš Avatar asked Sep 27 '13 17:09

Aleš


People also ask

Is JMC part of JDK?

JMC 5.5 no longer bundled with JDK 7 and JDK 8 JMC 8 is available as a compressed archive (zip for Windows and tar. gz for macOS and Linux), and requires JDK 11 or later to run. Starting with JDK 8, JDK Mission Control is provided as a separate download.

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.

Is Java Flight Recorder free?

The Java Flight Recorder (JFR) is a commercial feature. You can use it for free on developer desktops/laptops, and for evaluation purposes in test, development, and production environments.


1 Answers

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)

like image 86
Kire Haglin Avatar answered Sep 19 '22 14:09

Kire Haglin