我们可以从
1):选项 -XX:+PrintGCTimeStamps 将在每个集合开始时添加一个时间戳。这对于查看垃圾收集发生的频率很有用。
使用上述选项,我们可以粗略估计您是否认为该进程是英雄 GC'ing 导致 CPU 峰值。
如果您的假设是正确的,那么开始调整您的 GC 。
Both parallel collector and Concurrent Collector will throw an OutOfMemoryError if too much time is being
spent in garbage collection: if more than 98% of the total time is spent in garbage collection and
less than 2% of the heap is recovered, an OutOfMemoryError will be thrown. the option X:-UseGCOverheadLimit
is enabled by default for both Parallel and concurrent collector . Check whether this option is disabled in
your system .
有关 JVM 中 Gc 调优的更多信息,请参阅此内容,对于 vm 调试选项,请检查此内容