我没有指定任何GC,而且我认为我的JVM默认情况下没有启用任何GC。
当然,我知道OpenJDK8默认使用ParallelGC,但我认为它应该可以通过命令行打印出来,就像这样:
上面的输出表明没有任何垃圾回收被启用(我认为是这样),这种情况让我很困惑。
GC日志输出如下:
当然,我知道OpenJDK8默认使用ParallelGC,但我认为它应该可以通过命令行打印出来,就像这样:
java -XX:+PrintFlagsFinal|grep Use|grep GC
我希望输出包含bool UseParallelOldGC = true {product}
,但实际上并没有: bool ParGCUseLocalOverflow = false {product}
bool UseAdaptiveGCBoundary = false {product}
bool UseAdaptiveSizeDecayMajorGCCost = true {product}
bool UseAdaptiveSizePolicyWithSystemGC = false {product}
bool UseAutoGCSelectPolicy = false {product}
bool UseConcMarkSweepGC = false {product}
bool UseDynamicNumberOfGCThreads = false {product}
bool UseG1GC = false {product}
bool UseGCLogFileRotation = false {product}
bool UseGCOverheadLimit = true {product}
bool UseGCTaskAffinity = false {product}
bool UseMaximumCompactionOnSystemGC = true {product}
bool UseParNewGC = false {product}
bool UseParallelGC = false {product}
bool UseParallelOldGC = false {product}
bool UseSerialGC = false {product}
并且
java -XX:+PrintCommandLineFlags -version
我期望输出结果包含:XX:+UseParallelGC
但实际上并没有:
-XX:InitialHeapSize=460493056 -XX:MaxHeapSize=7367888896 -XX:+PrintCommandLineFlags -XX:+UseCompressedClassPointers -XX:+UseCompressedOops
.
我的JVM选项:
-XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -verbose:gc -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime
.
上面的输出表明没有任何垃圾回收被启用(我认为是这样),这种情况让我很困惑。
GC日志输出如下:
OpenJDK 64-Bit Server VM (25.181-b13) for linux-amd64 JRE (1.8.0_181-b13), built on Oct 23 2018 11:39:12 by "buildozer" with gcc 6.4.0
Memory: 4k page, physical 28780816k(6283132k free), swap 0k(0k free)
CommandLine flags: -XX:InitialHeapSize=460493056 -XX:MaxHeapSize=7367888896 -XX:+PrintGC -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDateStamps -XX:+PrintGCDeta
ils -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -XX:+UseCompressedClassPointers -XX:+UseCompressedOops
{Heap before GC invocations=0 (full 0):
def new generation total 135168K, used 120192K [0x0000000608c00000, 0x0000000611ea0000, 0x000000069b2a0000)
eden space 120192K, 100% used [0x0000000608c00000, 0x0000000610160000, 0x0000000610160000)
from space 14976K, 0% used [0x0000000610160000, 0x0000000610160000, 0x0000000611000000)
to space 14976K, 0% used [0x0000000611000000, 0x0000000611000000, 0x0000000611ea0000)
tenured generation total 300416K, used 0K [0x000000069b2a0000, 0x00000006ad800000, 0x00000007c0000000)
the space 300416K, 0% used [0x000000069b2a0000, 0x000000069b2a0000, 0x000000069b2a0200, 0x00000006ad800000)
Metaspace used 20532K, capacity 20780K, committed 20992K, reserved 1067008K
class space used 2628K, capacity 2726K, committed 2816K, reserved 1048576K
2019-02-25T06:29:46.105+0000: 2.890: [GC (Allocation Failure) 2019-02-25T06:29:46.105+0000: 2.890: [DefNew
Desired survivor size 7667712 bytes, new threshold 1 (max 15)
- age 1: 15335424 bytes, 15335424 total
: 120192K->14976K(135168K), 0.0238110 secs] 120192K->18041K(435584K), 0.0238765 secs] [Times: user=0.01 sys=0.01, real=0.02 secs]
Heap after GC invocations=1 (full 0):
def new generation total 135168K, used 14976K [0x0000000608c00000, 0x0000000611ea0000, 0x000000069b2a0000)
eden space 120192K, 0% used [0x0000000608c00000, 0x0000000608c00000, 0x0000000610160000)
from space 14976K, 100% used [0x0000000611000000, 0x0000000611ea0000, 0x0000000611ea0000)
to space 14976K, 0% used [0x0000000610160000, 0x0000000610160000, 0x0000000611000000)
tenured generation total 300416K, used 3065K [0x000000069b2a0000, 0x00000006ad800000, 0x00000007c0000000)
the space 300416K, 1% used [0x000000069b2a0000, 0x000000069b59e660, 0x000000069b59e800, 0x00000006ad800000)
Metaspace used 20532K, capacity 20780K, committed 20992K, reserved 1067008K
class space used 2628K, capacity 2726K, committed 2816K, reserved 1048576K
}
2019-02-25T06:29:46.129+0000: 2.914: Total time for which application threads were stopped: 0.0241189 seconds, Stopping threads took: 0.0000181 seconds
{Heap before GC invocations=1 (full 0):
def new generation total 135168K, used 21860K [0x0000000608c00000, 0x0000000611ea0000, 0x000000069b2a0000)
eden space 120192K, 5% used [0x0000000608c00000, 0x00000006092b93f8, 0x0000000610160000)
from space 14976K, 100% used [0x0000000611000000, 0x0000000611ea0000, 0x0000000611ea0000)
to space 14976K, 0% used [0x0000000610160000, 0x0000000610160000, 0x0000000611000000)
tenured generation total 300416K, used 3065K [0x000000069b2a0000, 0x00000006ad800000, 0x00000007c0000000)
the space 300416K, 1% used [0x000000069b2a0000, 0x000000069b59e660, 0x000000069b59e800, 0x00000006ad800000)
Metaspace used 20982K, capacity 21132K, committed 21248K, reserved 1067008K
class space used 2667K, capacity 2758K, committed 2816K, reserved 1048576K
2019-02-25T06:29:46.187+0000: 2.972: [Full GC (Metadata GC Threshold) 2019-02-25T06:29:46.187+0000: 2.972: [Tenured: 3065K->9617K(300416K), 0.0270556 secs] 24926K-
>9617K(435584K), [Metaspace: 20982K->20982K(1067008K)], 0.0271334 secs] [Times: user=0.03 sys=0.00, real=0.03 secs]
Heap after GC invocations=2 (full 1):
def new generation total 135296K, used 0K [0x0000000608c00000, 0x0000000611ec0000, 0x000000069b2a0000)
eden space 120320K, 0% used [0x0000000608c00000, 0x0000000608c00000, 0x0000000610180000)
from space 14976K, 0% used [0x0000000610180000, 0x0000000610180000, 0x0000000611020000)
to space 14976K, 0% used [0x0000000611020000, 0x0000000611020000, 0x0000000611ec0000)
tenured generation total 300416K, used 9617K [0x000000069b2a0000, 0x00000006ad800000, 0x00000007c0000000)
the space 300416K, 3% used [0x000000069b2a0000, 0x000000069bc04698, 0x000000069bc04800, 0x00000006ad800000)
Metaspace used 20982K, capacity 21132K, committed 21248K, reserved 1067008K
class space used 2667K, capacity 2758K, committed 2816K, reserved 1048576K
}
(从应用程序启动到第一次重要GC)
日志显示JVM堆被分为新生代(new)
和年老代(tenured)
,但不会打印GC类型。
遗憾的是,在我的环境中,我也无法使用jmap -heap {pid}
来获取GC类型,因为jmap没有这个选项(-heap)。
所以我想知道:
- 我真正使用的是哪种GC?
- 命令行选项(
-XX:+PrintCommandLineFlags
和-XX:+PrintFlagsFinal
)输出的信息是否正确?
我的环境: k8s+docker,Alpine OpenJKD8