環境版本,Java1.8,GC日志參數
-XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCApplicationStoppedTime
-XX:+PrintGCApplicationConcurrentTime -XX:+PrintHeapAtGC
YoungGC找到一條輸出的日志:
2335.667: Total time for which application threads were stopped: 0.0042227 seconds, Stopping threads took: 0.0000467 seconds
2335.879: Application time: 0.2122459 seconds
{Heap before GC invocations=741 (full 3):
def new generation total 176960K, used 157479K [0x00000000e8000000, 0x00000000f4000000, 0x00000000f4000000)
eden space 157312K, 100% used [0x00000000e8000000, 0x00000000f19a0000, 0x00000000f19a0000)
from space 19648K, 0% used [0x00000000f19a0000, 0x00000000f19c9fe8, 0x00000000f2cd0000)
to space 19648K, 0% used [0x00000000f2cd0000, 0x00000000f2cd0000, 0x00000000f4000000)
tenured generation total 196608K, used 47047K [0x00000000f4000000, 0x0000000100000000, 0x0000000100000000)
the space 196608K, 23% used [0x00000000f4000000, 0x00000000f6df1ec8, 0x00000000f6df2000, 0x0000000100000000)
Metaspace used 67465K, capacity 70294K, committed 70552K, reserved 1110016K
class space used 8778K, capacity 9290K, committed 9368K, reserved 1048576K
日志分析:
1)2335.667: Total time for which application threads were stopped: 0.0042227 seconds, Stopping threads took: 0.0000467 seconds
2335.667: 這裡表示JVM執行了多久時間,機關是秒。在gc的時候,顯示程式暫停的時間
2)2335.879: Application time: 0.2122459 seconds
表示在發生GC的時候,程式執行的時間,由于是tomcat的日志,這個表示請求響應時間為0.2122459 seconds
3)新生代區gc日志
def new generation total 176960K, used 157479K 新生去總共176960K,已使用157479K
eden space 157312K, 100% used //伊甸區
from space 19648K, 0% used //From Survivor,占新生代10%
to space 19648K, 0% used //To Surivor,占新生代10%
Survivor的目的,減少進入老年代的對象,進而減少fullGC的次數
4)老年代占用
tenured generation total 196608K, used 47047K
5)永久區占用
Metaspace used 67465K, capacity 70294K, committed 70552K, reserved 1110016K
class space used 8778K, capacity 9290K, committed 9368K, reserved 1048576K