G1是否有限制,有些文章提到最大区域大小为32M,最大区域数量为2K,因此最大堆大小似乎为64GB。 但是在我们的集群中,当堆为106GB时,它运行良好:
Garbage-First (G1) GC with 18 thread(s)
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 113816633344 (108544.0MB)
NewSize = 1363144 (1.2999954223632812MB)
MaxNewSize = 68283269120 (65120.0MB)
OldSize = 5452592 (5.1999969482421875MB)
NewRatio = 2
SurvivorRatio = 8
MetaspaceSize = 21807104 (20.796875MB)
CompressedClassSpaceSize = 1073741824 (1024.0MB)
MaxMetaspaceSize = 134217728 (128.0MB)
G1HeapRegionSize = 33554432 (32.0MB)
Heap Usage:
G1 Heap:
regions = 3392
capacity = 113816633344 (108544.0MB)
used = 72851759528 (69476.85196685791MB)
free = 40964873816 (39067.14803314209MB)
64.00800778196668% used
G1 Young Generation:
Eden Space:
regions = 535
capacity = 39426457600 (37600.0MB)
used = 17951621120 (17120.0MB)
free = 21474836480 (20480.0MB)
45.53191489361702% used
Survivor Space:
regions = 13
capacity = 436207616 (416.0MB)
used = 436207616 (416.0MB)
free = 0 (0.0MB)
100.0% used
G1 Old Generation:
regions = 1629
capacity = 73953968128 (70528.0MB)
used = 54463930792 (51940.85196685791MB)
free = 19490037336 (18587.14803314209MB)
73.64571796571278% used
18984 interned Strings occupying 2233784 bytes.
对比CMS,使用G1进程使用更多VSZ(超过近8GB),并使用Native Memory Tracking,差异:
JDK8 + G1 :
GC (reserved=4599924KB, committed=4599924KB)
Internal (reserved=3611979KB, committed=3611979KB)
JDK8 + CMS :
GC (reserved=737869KB, committed=737869KB)
Internal (reserved=5451KB, committed=5451KB)
在细节中,G1初始化两个堆:
[0x00007fca198d2386] ReservedSpace::initialize(unsigned long, unsigned long, bool, char*, unsigned long, bool)+0x256
[0x00007fca198d24ba] ReservedSpace::ReservedSpace(unsigned long, unsigned long)+0x6a
[0x00007fca193b1ef5] G1CollectedHeap::initialize()+0x475
[0x00007fca1989e753] Universe::initialize_heap()+0xf3
(reserved=1736704KB, committed=1736704KB)
[0x00007fca198d2386] ReservedSpace::initialize(unsigned long, unsigned long, bool, char*, unsigned long, bool)+0x256
[0x00007fca198d24ba] ReservedSpace::ReservedSpace(unsigned long, unsigned long)+0x6a
[0x00007fca193b1f75] G1CollectedHeap::initialize()+0x4f5
[0x00007fca1989e753] Universe::initialize_heap()+0xf3
(reserved=1736704KB, committed=1736704KB)
它似乎初始化两个G1堆满足106G堆?