From 9a07930424faf75c5c7b0b6699ef05ee873e0054 Mon Sep 17 00:00:00 2001 From: Maoni Stephens Date: Thu, 16 Mar 2017 17:57:49 -0700 Subject: [PATCH] need to account for the allocated bytes correctly for the following: (dotnet/coreclr#10162) need to account for the allocated bytes accurately for the following cases Commit migrated from https://github.com/dotnet/coreclr/commit/8bc067c194f0b44e95c6e6a490b99078a2fa9719 --- src/coreclr/src/gc/gc.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/coreclr/src/gc/gc.cpp b/src/coreclr/src/gc/gc.cpp index b4c0475..9551e9f 100644 --- a/src/coreclr/src/gc/gc.cpp +++ b/src/coreclr/src/gc/gc.cpp @@ -5800,9 +5800,10 @@ void gc_heap::fix_allocation_context (alloc_context* acontext, BOOL for_gc_p, alloc_contexts_used ++; } - if (for_gc_p) { + // We need to update the alloc_bytes to reflect the portion that we have not used + acontext->alloc_bytes -= (acontext->alloc_limit - acontext->alloc_ptr); acontext->alloc_ptr = 0; acontext->alloc_limit = acontext->alloc_ptr; } @@ -11375,6 +11376,13 @@ void gc_heap::adjust_limit_clr (uint8_t* start, size_t limit_size, } acontext->alloc_ptr = start; } + else + { + // If the next alloc context is right up against the current one it means we are absorbing the min + // object, so need to account for that. + acontext->alloc_bytes += (start - acontext->alloc_limit); + } + acontext->alloc_limit = (start + limit_size - aligned_min_obj_size); acontext->alloc_bytes += limit_size - ((gen_number < max_generation + 1) ? aligned_min_obj_size : 0); -- 2.7.4