Yes, GC.class_stats
is a high overhead diagnostic command, and it runs in a global safepoint (STW pause). Among other things, this operation walks through the whole heap to compute memory consumed by all instances of all loaded classes.
Furthermore, the operation causes Full GC. See the source code:
void ClassStatsDCmd::execute(DCmdSource source, TRAPS) {
VM_GC_HeapInspection heapop(output(),
true /* request_full_gc */);
heapop.set_csv_format(_csv.value());
heapop.set_print_help(_help.value());
heapop.set_print_class_stats(true);
...
VMThread::execute(&heapop); <-- VM_GC_HeapInspection runs in a global safepoint
}
jcmd <pid> help GC.class_stats
also warns that the command has high impact on the VM:
GC.class_stats
Provide statistics about Java class meta data.
Impact: High: Depends on Java heap size and content.
By the way, GC.class_stats
has been removed in JDK 15.