8339648: ZGC: Division by zero in rule_major_allocation_rate

Reviewed-by: aboldtch, lucy, tschatzl
This commit is contained in:
Matthias Baesken
2024-09-17 11:58:58 +00:00
parent 269cd38b55
commit 80db6e71b0

View File

@@ -488,7 +488,8 @@ static bool rule_major_allocation_rate(const ZDirectorStats& stats) {
// Calculate the GC cost for each reclaimed byte
const double current_young_gc_time_per_bytes_freed = double(young_gc_time) / double(reclaimed_per_young_gc);
const double current_old_gc_time_per_bytes_freed = double(old_gc_time) / double(reclaimed_per_old_gc);
const double current_old_gc_time_per_bytes_freed = reclaimed_per_old_gc == 0 ? std::numeric_limits<double>::infinity()
: (double(old_gc_time) / double(reclaimed_per_old_gc));
// Calculate extra time per young collection inflicted by *not* doing an
// old collection that frees up memory in the old generation.