关于jvm:JVM的GC日志解读

6次阅读

共计 3950 个字符,预计需要花费 10 分钟才能阅读完成。

{Heap before GC invocations=35866 (full 34):
 par new generation   total 290176K, used 287809K [0x00000000d4400000, 0x00000000e7000000, 0x00000000e7000000)
  eden space 273152K, 100% used [0x00000000d4400000, 0x00000000e4ec0000, 0x00000000e4ec0000)
  from space 17024K,  86% used [0x00000000e4ec0000, 0x00000000e5d10770, 0x00000000e5f60000)
  to   space 17024K,   0% used [0x00000000e5f60000, 0x00000000e5f60000, 0x00000000e7000000)
 concurrent mark-sweep generation total 409600K, used 159259K [0x00000000e7000000, 0x0000000100000000, 0x0000000100000000)
 Metaspace       used 137146K, capacity 146452K, committed 147072K, reserved 378880K
  class space    used 15581K, capacity 17238K, committed 17536K, reserved 247808K
2023-09-02T01:18:40.811+0000: 142176.656: [GC (Allocation Failure) 2023-09-02T01:18:40.811+0000: 142176.657: [ParNew: 287809K->13868K(290176K), 0.0142053 secs] 447069K->173146K(699776K), 0.0144550 secs] [Times: user=0.01 sys=0.00, real=0.01 secs]
Heap after GC invocations=35867 (full 34):
 par new generation   total 290176K, used 13868K [0x00000000d4400000, 0x00000000e7000000, 0x00000000e7000000)
  eden space 273152K,   0% used [0x00000000d4400000, 0x00000000d4400000, 0x00000000e4ec0000)
  from space 17024K,  81% used [0x00000000e5f60000, 0x00000000e6ceb260, 0x00000000e7000000)
  to   space 17024K,   0% used [0x00000000e4ec0000, 0x00000000e4ec0000, 0x00000000e5f60000)
 concurrent mark-sweep generation total 409600K, used 159277K [0x00000000e7000000, 0x0000000100000000, 0x0000000100000000)
 Metaspace       used 137146K, capacity 146452K, committed 147072K, reserved 378880K
  class space    used 15581K, capacity 17238K, committed 17536K, reserved 247808K
}
JVM 参数为:-Xms700m -Xmx700m -Xmn300m -XX:MetaspaceSize=250m -XX:MaxMetaspaceSize=250m -XX:SurvivorRatio=16

如上是一段 GC 日志,先来解读这一行:

2023-09-02T01:18:40.811+0000: 142176.656: [GC (Allocation Failure) 2023-09-02T01:18:40.811+0000: 142176.657: [ParNew: 287809K->13868K(290176K), 0.0142053 secs] 447069K->173146K(699776K), 0.0144550 secs] [Times: user=0.01 sys=0.00, real=0.01 secs]

2023-09-02T01:18:40.811+0000:示意的是一个日期格局

142176.656:零碎运行 142176.656 秒的时候产生。

GC:表明进行一次垃圾回收,后面没有 Full 润饰,表明这是一次 Minor GC。留神它不是示意只 GC 新生代。

(Allocation Failure):示意本次引起 GC 的起因是因为在年老代中没有足够的空间可能存储新的数据了。

ParNew:表明本次 GC 产生在年老代并且应用的是 ParNew 垃圾收集器。ParNew 是一个 Serial 收集器的多线程版本,会应用多个 CPU 和线程实现垃圾收集工作(默认应用的线程数和 CPU 数雷同,能够应用 -XX: ParallelGCThreads 参数限度)。该收集器采纳复制算法回收内存,期间会进行其余工作线程,即 Stop The World。

287809K->13868K(290176K):单位是 KB
三个参数别离为:GC 前该内存区域(这里是年老代)应用容量,GC 后该内存区域应用容量,该内存区域的总容量(Eden 区 + 1 个 Survivor 区)。

0.0142053 secs:该内存区域 GC 耗时,单位是秒。

447069K->173146K(699776K):三个参数别离为:堆区垃圾回收前的大小,堆区垃圾回收后的大小,堆区总大小。

0.0144550 secs:该内存区域 GC 耗时,单位是秒。

[Times: user=0.01 sys=0.00, real=0.01 secs]:别离示意用户态耗时,内核态耗时和总耗时。

其余日志解读

如果设置了 PrintHeapAtGC 参数,则 HotSpot 在 GC 前后都会将 GC 堆的概要信息输入进去。
Heap before GC 和 Heap after GC 别离示意 GC 前后堆的信息的开始,invocations 示意 GC 的次数,能够看到 前面跟了个 invocations,这里 invocations 示意总的 GC 次数,能够发现在 after 之后,invocations 自增了,而 full 示意第几次 Full GC。
invocations 会随着零碎运行始终自增上来,通过这些信息能够很轻松的统计出一段时间的 GC 次数。

Heap before GC invocations=35866 (full 34):
 par new generation   total 290176K, used 287809K [0x00000000d4400000, 0x00000000e7000000, 0x00000000e7000000)
  eden space 273152K, 100% used [0x00000000d4400000, 0x00000000e4ec0000, 0x00000000e4ec0000)
  from space 17024K,  86% used [0x00000000e4ec0000, 0x00000000e5d10770, 0x00000000e5f60000)
  to   space 17024K,   0% used [0x00000000e5f60000, 0x00000000e5f60000, 0x00000000e7000000)

Heap after GC invocations=35867 (full 34):
par new generation   total 290176K, used 13868K [0x00000000d4400000, 0x00000000e7000000, 0x00000000e7000000)
  eden space 273152K,   0% used [0x00000000d4400000, 0x00000000d4400000, 0x00000000e4ec0000)
  from space 17024K,  81% used [0x00000000e5f60000, 0x00000000e6ceb260, 0x00000000e7000000)
  to   space 17024K,   0% used [0x00000000e4ec0000, 0x00000000e4ec0000, 0x00000000e5f60000)

再看上面的日志,能够看到年老代和老年代所应用的垃圾回收器,以及各自的状况。

新生代 par new generation 示意应用 ParNew 作为垃圾回收器,一共 290176 K 大小,应用了 287809 K 大小。其中 eden 区曾经满了,from survivor 用了 86%,to survivor 用了 0%,每个前面都跟了内存地址,头一个示意起始地址,第二个示意以后用到的最大地址,第三个示意终止地址。
察看 before 和 after,仔细点能够察看到 from 和 to 的地址对调了。

紧跟着 par new generation 前面的是 concurrent mark-sweep generation,总共的量 409600K,应用的量 159277K,地址能够分明的看到,前面跟着的三个参数同样是起止地址,而第二个和第三个是雷同的。
此外还给出了 Metaspace 的应用状况,以及 class space 的应用状况。这两个值初始会比拟小,在应用过程中会容量会逐渐扩充。

  • used:加载的类的空间量。
  • capacity:以后调配块的元数据的空间。
  • committed:空间块的数量。
  • reserved:元数据的空间保留(但不肯定提交)的量。
正文完
 0