Skip to content

Commit 204b492

Browse files
committed
8267703: runtime/cds/appcds/cacheObject/HeapFragmentationTest.java crashed with OutOfMemory
Reviewed-by: tschatzl, kbarrett
1 parent 2aeeeb4 commit 204b492

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/hotspot/share/gc/g1/g1ConcurrentMark.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,11 @@ void G1ConcurrentMark::cleanup_for_next_mark() {
680680

681681
void G1ConcurrentMark::clear_next_bitmap(WorkGang* workers) {
682682
assert_at_safepoint_on_vm_thread();
683+
// To avoid fragmentation the full collection requesting to clear the bitmap
684+
// might use fewer workers than available. To ensure the bitmap is cleared
685+
// as efficiently as possible the number of active workers are temporarily
686+
// increased to include all currently created workers.
687+
WithUpdatedActiveWorkers update(workers, workers->created_workers());
683688
clear_bitmap(_next_mark_bitmap, workers, false);
684689
}
685690

src/hotspot/share/gc/g1/g1FullCollector.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,15 @@ uint G1FullCollector::calc_active_workers() {
9494
uint current_active_workers = heap->workers()->active_workers();
9595
uint active_worker_limit = WorkerPolicy::calc_active_workers(max_worker_count, current_active_workers, 0);
9696

97+
// Finally consider the amount of used regions.
98+
uint used_worker_limit = heap->num_used_regions();
99+
assert(used_worker_limit > 0, "Should never have zero used regions.");
100+
97101
// Update active workers to the lower of the limits.
98-
uint worker_count = MIN2(heap_waste_worker_limit, active_worker_limit);
99-
log_debug(gc, task)("Requesting %u active workers for full compaction (waste limited workers: %u, adaptive workers: %u)",
100-
worker_count, heap_waste_worker_limit, active_worker_limit);
102+
uint worker_count = MIN3(heap_waste_worker_limit, active_worker_limit, used_worker_limit);
103+
log_debug(gc, task)("Requesting %u active workers for full compaction (waste limited workers: %u, "
104+
"adaptive workers: %u, used limited workers: %u)",
105+
worker_count, heap_waste_worker_limit, active_worker_limit, used_worker_limit);
101106
worker_count = heap->workers()->update_active_workers(worker_count);
102107
log_info(gc, task)("Using %u workers of %u for full compaction", worker_count, max_worker_count);
103108

0 commit comments

Comments
 (0)