From d22909e0225e885b85c55b9242fb51c81e5256ad Mon Sep 17 00:00:00 2001 From: Maoni Stephens Date: Thu, 6 Jun 2024 01:12:48 -0700 Subject: [PATCH] need to account for unsuccessful commit case when hardlimit isn't on (#102961) since we turn on the commit accounting for cases when hardlimit isn't on, when it's unsuccessful, we should deduct the bytes from the accounting. --- src/coreclr/gc/gc.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index 2aba247257637..98e81eddd2c51 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -7318,10 +7318,14 @@ bool gc_heap::virtual_commit (void* address, size_t size, int bucket, int h_numb #endif //USE_REGIONS dprintf(3, ("commit-accounting: commit in %d [%p, %p) for heap %d", bucket, address, ((uint8_t*)address + size), h_number)); - -#ifndef USE_REGIONS - if (bucket != recorded_committed_ignored_bucket) + bool should_count = +#ifdef USE_REGIONS + true; +#else + (bucket != recorded_committed_ignored_bucket); #endif //USE_REGIONS + + if (should_count) { check_commit_cs.Enter(); bool exceeded_p = false; @@ -7381,7 +7385,7 @@ bool gc_heap::virtual_commit (void* address, size_t size, int bucket, int h_numb virtual_alloc_commit_for_heap (address, size, h_number)) : GCToOSInterface::VirtualCommit(address, size)); - if (!commit_succeeded_p && heap_hard_limit) + if (!commit_succeeded_p && should_count) { check_commit_cs.Enter(); committed_by_oh[bucket] -= size;