gpt4 book ai didi

java - 为什么垃圾收集日志元空间值与提供的标志不同?

转载 作者:行者123 更新时间:2023-11-30 08:30:22 25 4
gpt4 key购买 nike

我正在使用以下标志在 Java 8 上运行服务器应用程序:

-XX:GCLogFileSize=2097152 -XX:InitialBootClassLoaderMetaspaceSize=33554432 -XX:InitialHeapSize=1610612736 -XX:MaxHeapSize=1610612736 -XX:MaxMetaspaceSize=1073741824 -XX:MetaspaceSize=536870912 -XX:NumberOfGCLogFiles=5 -XX:+PrintGC -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseGCLogFileRotation -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC

元空间起始值为 512m,最大值为 1gb。

在 GC 日志中,我看到与上述标志值不同的元空间值。我的日志示例如下:

{Heap before GC invocations=1 (full 0):
PSYoungGen total 458752K, used 393216K [0x00000000e0000000, 0x0000000100000000, 0x0000000100000000)
eden space 393216K, 100% used [0x00000000e0000000,0x00000000f8000000,0x00000000f8000000)
from space 65536K, 0% used [0x00000000fc000000,0x00000000fc000000,0x0000000100000000)
to space 65536K, 0% used [0x00000000f8000000,0x00000000f8000000,0x00000000fc000000)
ParOldGen total 1048576K, used 0K [0x00000000a0000000, 0x00000000e0000000, 0x00000000e0000000)
object space 1048576K, 0% used [0x00000000a0000000,0x00000000a00003a0,0x00000000e0000000)
Metaspace used 26975K, capacity 54120K, committed 54400K, reserved 1114112K
class space used 3346K, capacity 4426K, committed 4480K, reserved 1048576K
2016-12-21T16:41:10.569+0300: 1.423: [GC (GCLocker Initiated GC) [PSYoungGen: 393216K->29645K(458752K)] 393216K->29734K(1507328K), 0.0241803 secs] [Times: user=0.11 sys=0.00, real=0.02 secs]
Heap after GC invocations=1 (full 0):
PSYoungGen total 458752K, used 29645K [0x00000000e0000000, 0x0000000100000000, 0x0000000100000000)
eden space 393216K, 0% used [0x00000000e0000000,0x00000000e0000000,0x00000000f8000000)
from space 65536K, 45% used [0x00000000f8000000,0x00000000f9cf3460,0x00000000fc000000)
to space 65536K, 0% used [0x00000000fc000000,0x00000000fc000000,0x0000000100000000)
ParOldGen total 1048576K, used 88K [0x00000000a0000000, 0x00000000e0000000, 0x00000000e0000000)
object space 1048576K, 0% used [0x00000000a0000000,0x00000000a00163b0,0x00000000e0000000)
Metaspace used 26975K, capacity 54120K, committed 54400K, reserved 1114112K
class space used 3346K, capacity 4426K, committed 4480K, reserved 1048576K
}

所以我的问题是:为什么我在 GC 日志中看不到元空间的 512m 和 1gb 值?日志值是否与标志没有直接关系?

最佳答案

“Advanced Garbage Collection Options” 中所述:

-XX:MetaspaceSize= size

Sets the size of the allocated class metadata space that will trigger a garbage collection the first time it is exceeded. This threshold for a garbage collection is increased or decreased depending on the amount of metadata used. The default size depends on the platform.

换句话说,它没有指定初始大小,而是指定了第一次 gc 阈值,因此它符合您观察到的没有完整 gc 而实际元空间大小小于指定大小的行为。

一旦第一次超过阈值,JVM 可能会根据实际使用情况选择一个新的阈值。

关于java - 为什么垃圾收集日志元空间值与提供的标志不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41264844/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com