Skip to content

Commit

Permalink
fixed a bug in updating the gen0 budget for AllocateUninitializedArray (
Browse files Browse the repository at this point in the history
#37148)

For AllocateUninitializedArray, we don't consume all the memory we get
from the gen0 budget but we are not putting back the part we don't consume.
This artificial consumption in budget can mean we trigger a GC way too early
when we haven't actually allocated that much.
  • Loading branch information
Maoni0 committed May 29, 2020
1 parent fec84ae commit 27dcce5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/coreclr/src/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12321,7 +12321,14 @@ BOOL gc_heap::a_fit_segment_end_p (int gen_number,
assert(gen_number == 0);
assert(allocated > acontext->alloc_ptr);

limit -= (allocated - acontext->alloc_ptr);
size_t extra = allocated - acontext->alloc_ptr;
limit -= extra;

// Since we are not consuming all the memory we already deducted from the budget,
// we should put the extra back.
dynamic_data* dd = dynamic_data_of (0);
dd_new_allocation (dd) += extra;

// add space for an AC continuity divider
limit += Align(min_obj_size, align_const);
}
Expand Down

0 comments on commit 27dcce5

Please sign in to comment.