JAVA -XX:+PrintGCDetails 日志解析--youngGen 撑爆

[GC (Allocation Failure) [PSYoungGen: 22716K->680K(33280K)] 22716K->7810K(110080K), 0.0929256 secs] [Times: user=0.13 sys=0.00, real=0.09 secs] 
[GC (Allocation Failure) [PSYoungGen: 27946K->536K(61952K)] 1219072K->1191662K(1277440K), 1.5353892 secs] [Times: user=5.65 sys=0.00, real=1.54 secs] 
[Full GC (Ergonomics) [PSYoungGen: 536K->0K(61952K)] [ParOldGen: 1191126K->411216K(518144K)] 1191662K->411216K(580096K), [Metaspace: 2649K->2649K(1056768K)], 5.8826551 secs] [Times: user=7.39 sys=0.26, real=5.88 secs] 
[GC (Allocation Failure) [PSYoungGen: 0K->0K(61952K)] 1027251K->1027251K(1277440K), 0.3472131 secs] [Times: user=1.28 sys=0.00, real=0.35 secs] 
[GC (Allocation Failure) [PSYoungGen: 0K->0K(75776K)] 1027251K->1027251K(1291264K), 0.3555830 secs] [Times: user=1.33 sys=0.00, real=0.36 secs] 
[Full GC (Allocation Failure) [PSYoungGen: 0K->0K(75776K)] [ParOldGen: 1027251K->616561K(798720K)] 1027251K->616561K(874496K), [Metaspace: 2649K->2649K(1056768K)], 10.4673778 secs] [Times: user=12.92 sys=0.11, real=10.47 secs] 
[GC (Allocation Failure) [PSYoungGen: 0K->0K(75776K)] 616561K->616561K(1291264K), 0.0191145 secs] [Times: user=0.03 sys=0.00, real=0.02 secs] 
[Full GC (Allocation Failure) [PSYoungGen: 0K->0K(75776K)] [ParOldGen: 616561K->616549K(842752K)] 616561K->616549K(918528K), [Metaspace: 2649K->2649K(1056768K)], 13.6213425 secs] [Times: user=16.24 sys=0.03, real=13.62 secs] 
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at java.util.Arrays.copyOf(Arrays.java:3210)
	at java.util.Arrays.copyOf(Arrays.java:3181)
	at java.util.ArrayList.grow(ArrayList.java:265)
	at java.util.ArrayList.ensureExplicitCapacity(ArrayList.java:239)
	at java.util.ArrayList.ensureCapacityInternal(ArrayList.java:231)
	at java.util.ArrayList.add(ArrayList.java:462)
	at test.TestGC.main(TestGC.java:11)
Heap
 PSYoungGen      total 75776K, used 2823K [0x00000000daf00000, 0x00000000e0b00000, 0x0000000100000000)
  eden space 71168K, 3% used [0x00000000daf00000,0x00000000db1c1f00,0x00000000df480000)
  from space 4608K, 0% used [0x00000000df480000,0x00000000df480000,0x00000000df900000)
  to   space 1024K, 0% used [0x00000000e0a00000,0x00000000e0a00000,0x00000000e0b00000)
 ParOldGen       total 1215488K, used 616549K [0x0000000090c00000, 0x00000000daf00000, 0x00000000daf00000)
  object space 1215488K, 50% used [0x0000000090c00000,0x00000000b66195a0,0x00000000daf00000)
 Metaspace       used 2681K, capacity 4486K, committed 4864K, reserved 1056768K
  class space    used 288K, capacity 386K, committed 512K, reserved 1048576K
GC (Allocation Failure) [PSYoungGen: 22716K->680K(33280K)] 22716K->7810K(110080K), 0.0929256 secs] [Times: user=0.13 sys=0.00, real=0.09 secs] 

这是一个young 区域撑爆的JAVA 内存日志,其中 PSYoungGen 表示 youngGen分区的变化 

22716k 表示 GC 之前的大小。

680k 表示GC 之后的大小。

整个Young区域的大小从22716k到7810k, young代的总大小为110080k

0.0929256s gc 暂停STW 时间, 然后有不同侧面来描述

[Times: user=0.13 sys=0.00, real=0.09 secs] 
user – 总计本次 GC 总线程所占用的总 CPU 时间 
sys – OS 调用 or 等待系统时间

real – 应用暂停时间,如果GC 线程是 Serial Garbage Collector单线程的方式的话,  real time 等于user 和 system 时间之和.

如果GC 是多线程的方式的话,user 值可能会大于real.

通过日志发现Young的区域到最后 GC 之前后都是0,old 区域 无法释放,最后抱堆溢出错误。

参考 https://dzone.com/articles/understanding-garbage

你可能感兴趣的:(java)