aboutsummaryrefslogtreecommitdiffstats
path: root/gc.c
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2021-06-02 14:42:09 -0400
committerPeter Zhu <peter@peterzhu.ca>2021-06-02 15:49:32 -0400
commitad734a8cc3181cb4ad510e3c7dc73dd8bb943742 (patch)
tree0889a41194f44e7440d0f20740a6eca0a65ace89 /gc.c
parent2a685da1fcd928530509e99f5edb4117bc377994 (diff)
downloadruby-ad734a8cc3181cb4ad510e3c7dc73dd8bb943742.tar.gz
Allocate exact space for objspace_each_objects
We are only iterating over the eden heap so `heap_eden->total_pages` contains the exact number of pages we need to allocate for. `heap_allocated_pages` may contain pages in the tomb.
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gc.c b/gc.c
index 7f1ff7ce0f..903d23c4c9 100644
--- a/gc.c
+++ b/gc.c
@@ -3635,7 +3635,7 @@ objspace_each_objects(rb_objspace_t *objspace, each_obj_callback *callback, void
}
/* Create pages buffer */
- size_t size = size_mul_or_raise(heap_allocated_pages, sizeof(struct heap_page *), rb_eRuntimeError);
+ size_t size = size_mul_or_raise(heap_eden->total_pages, sizeof(struct heap_page *), rb_eRuntimeError);
struct heap_page **pages = malloc(size);
if (!pages) rb_memerror();
@@ -3650,7 +3650,7 @@ objspace_each_objects(rb_objspace_t *objspace, each_obj_callback *callback, void
pages[pages_count] = page;
pages_count++;
}
- GC_ASSERT(pages_count <= heap_allocated_pages);
+ GC_ASSERT(pages_count == heap_eden->total_pages);
/* Run the callback */
struct each_obj_data each_obj_data = {