nit: comments to explain why mutator_allocator_remaining_bytes needs to be added back when reset bytes_allocated_since_gc_start

This commit is contained in:
Xiaolong Peng 2026-04-09 10:44:43 -07:00
parent d6543f9006
commit 08b4245d70
2 changed files with 2 additions and 0 deletions

View File

@ -694,6 +694,7 @@ public:
// Return an approximation of the bytes allocated since GC start. The value returned is monotonically non-decreasing
// in time within each GC cycle. For certain GC cycles, the value returned may include some bytes allocated before
// the start of the current GC cycle.
// Bytes allocated since gc start includes the total unused bytes in mutator allocator reserved for CAS allocation.
inline size_t get_bytes_allocated_since_gc_start() const {
return _mutator_bytes_allocated_since_gc_start;
}

View File

@ -2293,6 +2293,7 @@ void ShenandoahHeap::reset_bytes_allocated_since_gc_start() {
// Single-gen Shenandoah uses global heuristics.
unaccounted_bytes = heuristics()->force_alloc_rate_sample(actual_allocated);
}
// Bytes allocated since gc start includes the total unused bytes in mutator allocator reserved for CAS allocation.
_free_set->reset_bytes_allocated_since_gc_start(unaccounted_bytes + mutator_allocator_remaining_bytes);
}