diff options
author | Peter Zhu <peter.zhu@shopify.com> | 2021-09-13 09:19:10 -0400 |
---|---|---|
committer | Peter Zhu <peter@peterzhu.ca> | 2021-09-15 09:00:42 -0400 |
commit | a65ac2d6fa4e7381d88b79a2881f7c05daa903c3 (patch) | |
tree | 7f0b57e4255e7f841d882b196afa764adb25ceed | |
parent | e624d0d202ef691f5c75841b90bf44a624e3cdcc (diff) |
Don't overwrite free_slots count during sweeping
gc_compact_finish may invalidate pages, which may move objects from this
page to other pages, which updates the free_slots of this page.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4831
-rw-r--r-- | gc.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -5414,6 +5414,7 @@ gc_page_sweep(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *hea } sweep_page->flags.before_sweep = FALSE; + sweep_page->free_slots = 0; p = sweep_page->start; bits = sweep_page->mark_bits; @@ -5462,7 +5463,7 @@ gc_page_sweep(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *hea sweep_page->total_slots, ctx->freed_slots, ctx->empty_slots, ctx->final_slots); - sweep_page->free_slots = ctx->freed_slots + ctx->empty_slots; + sweep_page->free_slots += ctx->freed_slots + ctx->empty_slots; objspace->profile.total_freed_objects += ctx->freed_slots; if (heap_pages_deferred_final && !finalizing) { |