Skip to content

Commit 1cc3223

Browse files
committed
8336911: ZGC: Division by zero in heuristics after JDK-8332717
Reviewed-by: aboldtch, eosterlund
1 parent cf5bb12 commit 1cc3223

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/hotspot/share/gc/z/zDirector.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,19 @@ static double calculate_young_to_old_worker_ratio(const ZDirectorStats& stats) {
535535
const size_t reclaimed_per_old_gc = stats._old_stats._stat_heap._reclaimed_avg;
536536
const double current_young_bytes_freed_per_gc_time = double(reclaimed_per_young_gc) / double(young_gc_time);
537537
const double current_old_bytes_freed_per_gc_time = double(reclaimed_per_old_gc) / double(old_gc_time);
538+
539+
if (current_young_bytes_freed_per_gc_time == 0.0) {
540+
if (current_old_bytes_freed_per_gc_time == 0.0) {
541+
// Neither young nor old collections have reclaimed any memory.
542+
// Give them equal priority.
543+
return 1.0;
544+
}
545+
546+
// Only old collections have reclaimed memory.
547+
// Prioritize old.
548+
return ZOldGCThreads;
549+
}
550+
538551
const double old_vs_young_efficiency_ratio = current_old_bytes_freed_per_gc_time / current_young_bytes_freed_per_gc_time;
539552

540553
return old_vs_young_efficiency_ratio;

0 commit comments

Comments
 (0)