Skip to content

Commit

Permalink
Fix heap growth in GC.verify_compaction_references
Browse files Browse the repository at this point in the history
We should grow by at least gc_params.heap_init_slots, but the previous
calculation was incorrect.
  • Loading branch information
peterzhu2118 committed Jun 6, 2023
1 parent 1f64301 commit c3dc9fc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions gc.c
Expand Up @@ -10846,13 +10846,13 @@ gc_verify_compaction_references(rb_execution_context_t *ec, VALUE self, VALUE do
rb_size_pool_t *size_pool = &size_pools[i];
rb_heap_t *heap = SIZE_POOL_EDEN_HEAP(size_pool);

size_t minimum_pages = 0;
if (RTEST(expand_heap)) {
size_t required_pages = growth_slots / size_pool->slot_size;
heap_add_pages(objspace, size_pool, heap, MAX(required_pages, heap->total_pages));
}
else {
heap_add_pages(objspace, size_pool, heap, heap->total_pages);
int multiple = size_pool->slot_size / BASE_SLOT_SIZE;
minimum_pages = growth_slots * multiple / HEAP_PAGE_OBJ_LIMIT;
}

heap_add_pages(objspace, size_pool, heap, MAX(minimum_pages, heap->total_pages));
}
}

Expand Down

0 comments on commit c3dc9fc

Please sign in to comment.