在收集数据之前,"jcmd PID GC.class_histogram"会调用完整的GC吗? [英] Will `jcmd PID GC.class_histogram` call a full GC before collecting data?
问题描述
运行jcmd PID help GC.heap_dump
时,帮助会明确说明将调用完整的GC,除非指定了-all
标志:
When I run jcmd PID help GC.heap_dump
, the help clearly says that full GC will be called, unless -all
flag is specified:
GC.heap_dump ... 影响:高:取决于Java堆的大小和内容.除非指定'-all'选项,否则请求完整的GC. < ...>
GC.heap_dump ... Impact: High: Depends on Java heap size and content. Request a full GC unless the '-all' option is specified. <...>
-all:[可选]检查所有对象,包括不可达的对象(BOOLEAN,false)
-all : [optional] Inspect all objects, including unreachable objects (BOOLEAN, false)
如果我运行jcmd PID help GC.class_histogram
,则帮助没有说明强制使用完整的GC,但是"Impact"仍然被认为是高",并且该选项仍然具有-all
标志,其行为完全相同至于GC.heap_dump
:
If I run jcmd PID help GC.class_histogram
, the help doesn't say anything about forcing a full GC, however "Impact" is still said to be "high", and the option still has an -all
flag, which behaves exactly as for GC.heap_dump
:
GC.class_histogram ... 影响:高:取决于Java堆的大小和内容.
GC.class_histogram ... Impact: High: Depends on Java heap size and content.
-all:[可选]检查所有对象,包括不可达的对象(BOOLEAN,false)
-all : [optional] Inspect all objects, including unreachable objects (BOOLEAN, false)
我尝试在几个环境中运行此命令,但未调用完整GC.但是,由于它取决于Java堆的大小和内容" ,所以我不确定.
I tried to run this command on couple of environments, and full GC was not called. However, since it "Depends on Java heap size and content" I cannot be sure.
那么jcmd PID GC.class_histogram
在某些情况下可以调用完整的GC吗?如果是,那是什么?
So can jcmd PID GC.class_histogram
call a full GC in some circumstances? If yes, what are they?
推荐答案
jcmd PID GC.class_histogram
默认情况下将导致Full GC.
jcmd PID GC.class_histogram
will cause Full GC by default.
如果目标JVM是使用-XX:+PrintGC
启动的,您将看到一条日志消息,如
If the target JVM is launched with -XX:+PrintGC
, you will see a log message like
// JDK 8:
[Full GC (Heap Inspection Initiated GC) 1397K->331K(126720K), 0.0023298 secs]
// JDK 9:
[15.503s][info ][gc] GC(0) Pause Full (Heap Inspection Initiated GC) 2M->0M(8M) 8.107ms
但是,使用-all
选项时,与GC.heap_dump
完全一样,对于GC.class_histogram
没有完全GC.在热点来源:
However, with -all
option there will be no Full GC for GC.class_histogram
, exactly like for GC.heap_dump
. Find the proof in HotSpot sources:
void ClassHistogramDCmd::execute(DCmdSource source, TRAPS) {
VM_GC_HeapInspection heapop(output(),
!_all.value() /* request full gc if false */);
VMThread::execute(&heapop);
}
这篇关于在收集数据之前,"jcmd PID GC.class_histogram"会调用完整的GC吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!