JVM PrintGCApplicationConcurrentTime 和 PrintGCApplicationStoppedTime 标志

JVM PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime flags

我是 运行 一个 Java 程序,我需要了解每个程序在垃圾收集上花费了多少时间。 我找到了这两个 JVM 标志: -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCApplicationStoppedTime

但我找不到相关信息。 我想 PrintGCApplicationStoppedTime 打印了申请时间在 STW 中的时间,但是我不确定 -XX:+PrintGCApplicationConcurrentTime。它是否打印应用程序与收集线程同时执行了多长时间?

提前致谢。

这些标志的名称不是很准确。

PrintGCApplicationStoppedTime 显示应用程序在安全点停止的时间。大多数情况下,安全点是由垃圾收集的 stop-the-world 阶段引起的,但是,.

PrintGCApplicationConcurrentTime 是应用程序不间断运行的时间,即两个连续安全点之间的时间。

您使用这些标志来了解您的申请需要多长时间 在垃圾收集 之间运行。

最终可以从 GC 日志,但查看该信息的便捷方式是使用 命令行标志 -XX:+PrintGCApplicationStoppedTime-XX:+PrintGCApplicationConcurrentTime

将这些添加到命令行会产生如下输出:

Application time: 0.2863875 seconds
Total time for which application threads were stopped: 0.0225087 seconds
Application time: 0.1476791 seconds
Total time for which application threads were stopped: 0.0255697 seconds

应用程序运行(在第一行报告)大约287毫秒然后被 停止了大约 22 毫秒(在第二行报告)。

这些标志可以单独使用,也可以一起使用。