Skip to content

share jdk8_GCEasy show bug

wangkaiwu edited this page Feb 1, 2022 · 1 revision

G1 GC allocated memory is more than heap size

这是您的 Jvm 参数,单位是字节。23923261440(byte) = 22815(Mb) = 22.28(Gb)

-XX:InitialHeapSize=23923261440
-XX:MaxHeapSize=23923261440

默认情况下,G1 的 Young Gen 和 Old Gen 的空间占用不是固定的. 我从您分享的 GCEasy 页面的 Interactive Graphs 一栏中,按照时间线整理了以下信息。

GC Times Young Gen(Mb) Old Gen(Mb) Total(Mb)
First 1232 21584 22816
Fifth 1136 21680 22816
33th 5384 17432 22816
35th 1200 21616 22816
53th 13696 9120 22816
Last 13688 9128 22816

从上面的表格可以得出以下结论:

  1. 如果设置了 -Xms 且与 -Xmx 保持一致,那么 Young Gen 加上 Old Gen 会是一个固定值。
  2. Young Gen 的空间一直在变化,且有时候增加,有时候减少。而 old Gen 正好相反。

在 G1 中,由于 Young Gen 的空间总是实时变化,而 Parallel GC 中 Young Gen 的空间总是固定不变的。 因此 GCEasy 无法用一个唯一值来表示 G1 各 gen 的分配空间,于是它选择了取每个 Gen 在本次启动期间的最大值。 根据上面的图表,空间计算如下:

  • Young Gen 的最大值是: 13696(Mb) = 13.375(Gb) ≈ 13.38(Gb)
  • Old Gen 的最大值是: 21680(Mb) = 21.171(Gb) ≈ 21.17(Gb)

两个值的近似值正好与下图吻合

Generation Allocated Peak
Young Gen 13.38 3.37
Old Gen 21.17 485mb
Meta Space 1.5 n/a
Young + old + Meta 23.78 13.61

This is your JVM parameters ,the number is byte. 23923261440(byte) = 22815(Mb) = 22.28(Gb)

-XX:InitialHeapSize=23923261440
-XX:MaxHeapSize=23923261440

By default, the space of G1's Young Gen and Old Gen is not fixed.From the Interactive Graphs column of the GCEasy page you shared, I have organized the following information in a timeline.

GC Times Young Gen(Mb) Old Gen(Mb) Total(Mb)
First 1232 21584 22816
Fifth 1136 21680 22816
33th 5384 17432 22816
35th 1200 21616 22816
53th 13696 9120 22816
Last 13688 9128 22816

The following conclusions can be drawn from the table above:

  1. If -Xms is set and consistent with -Xmx, then Young Gen plus Old Gen will be a fixed value.
  2. The Young Gen space is always changing, sometimes increasing and sometimes decreasing. old Gen is the opposite.

In G1, the space of Young Gen is always changing after GC, the space of Young Gen in Parallel GC is always fixed. Therefore, GCEasy cannot use a unique value to represent the allocation space of each gen of G1, so it chooses to take each Gen The maximum value during application running. According to the table above, the space is calculated as follows:

  • The maximum value of Young Gen is: 13696(Mb) = 13.375(Gb) ≈ 13.38(Gb)
  • The maximum value of Old Gen is: 21680(Mb) = 21.171(Gb) ≈ 21.17(Gb)

The approximation of the two values exactly matches the table below.

Generation Allocated Peak
Young Gen 13.38 3.37
Old Gen 21.17 485mb
Meta Space 1.5 n/a
Young + old + Meta 23.78 13.61

Clone this wiki locally