GC日志中的stop-the-world

来源:互联网 发布:python udp server 编辑:程序博客网 时间:2024/06/15 05:11


       通常使用下面的JVM选项在GC日志中打印”stop-the-world”(STW)暂停时间。

-XX:+PrintGCApplicationStoppedTime
       但是在GC日志中看,会发现有许多这样的暂停时间,时间很短,肯定不是垃圾回收引起的。
Total time for which application threads were stopped: 0.0013102 seconds, Stopping threads took: 0.0001792 secondsTotal time for which application threads were stopped: 0.0012521 seconds, Stopping threads took: 0.0001591 secondsTotal time for which application threads were stopped: 0.0008090 seconds, Stopping threads took: 0.0001030 secondsTotal time for which application threads were stopped: 0.0010226 seconds, Stopping threads took: 0.0001058 seconds
       实际上,触发STW暂停的原因除了垃圾回收外,还有一些其他的操作会触发STW,例如一些JIT活动、偏向锁擦除、特定的JVMTI操作,以及许多场景也可能会导致应用程序暂停。
       上述例子中application threads stopped的时间表示应用暂停时间,Stopping threads took 的时间表示等待所有的应用线程都到达安全点花费的时间。只有应用程序线程到达安全点后,JVM才会做些特殊处理,比如垃圾收集、偏向锁擦除等等。

0 0