问题描述
我正在使用 Java 7u40 附带的新 Java Mission Control Profiler,但我无法配置文件分配和收集对象统计信息.无论我做什么,我都无法在 Memory -> Object Statistics 窗口中看到任何统计信息.
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.
以下命令启动集合:
jcmd <pid> JFR.start duration=60s settings=profile filename=alloc-prof.jfr
Java Mission Control 文档没有提及任何具体选项启用对象分析.我尝试创建自己的个人资料并设置:
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.
推荐答案
使用 Mission Control 中可用的模板管理器.
Use the template manager that is available in Mission Control.
转到 Windows -> 模板管理器并导入模板并检查堆统计和分配分析,将其导出.完成!
Go to Windows -> Template Manager and import the template and check Heap Statistics and Allocation Profiling, export it. Done!
如果你想手动编辑jfc文件,最好知道控制元素里面的元素不被JVM读取,即标志元素,它们被JMC用来修改控制之外的参数元素(具有控制属性的元素)
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:
将 java/object_alloc_in_new_TLAB 设置为 true
set java/object_alloc_in_new_TLAB enabled to true
将 java/object_alloc_outside_TLAB 设置为 true
set java/object_alloc_outside_TLAB enabled to true
将启用的 vm/gc/detailed/object_count 设置为 true
set vm/gc/detailed/object_count enabled to true
注意,有两个对象计数事件,使用 object_count_after_gc 会增加 GC 次数.如果你选择上面的那个,你会得到一个额外的 GC 每个记录块(通常就足够了)
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)
这篇关于Java 任务控制堆配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!