--- old/src/hotspot/share/gc/g1/heapRegion.cpp 2018-08-01 22:33:58.039775489 -0700 +++ new/src/hotspot/share/gc/g1/heapRegion.cpp 2018-08-01 22:33:57.699762558 -0700 @@ -66,6 +66,13 @@ size_t average_heap_size = (initial_heap_size + max_heap_size) / 2; region_size = MAX2(average_heap_size / HeapRegionBounds::target_number(), HeapRegionBounds::min_size()); + if (DumpSharedSpaces && max_heap_size >= 128*M && region_size < 8*M) { + // CDS archived heap supports up to 32G heaps, with region size up to 8MB. + // At CDS dump time, if we use small regions for G1, the CARC and OARC regions may end up + // in the same 8MB block. At run time with a large heap, G1CollectedHeap::alloc_archive_regions + // might fail because CARC and OARC will end up in the same G1 region. + region_size = 8*M; + } } int region_size_log = log2_long((jlong) region_size);