@@ -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