aboutsummaryrefslogtreecommitdiffstats
path: root/gc.c
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2019-10-07 12:28:21 -0700
committerAaron Patterson <tenderlove@ruby-lang.org>2019-10-07 12:28:21 -0700
commit6abcd35762db4bf49cd6c62a8c624e2a013e5dc1 (patch)
tree178acd740ca5f4cecaff9cafb988d042c6dc0a6a /gc.c
parent058db33c5ec881271d028b7490d88b3baed74acb (diff)
downloadruby-6abcd35762db4bf49cd6c62a8c624e2a013e5dc1.tar.gz
Do not free too many pages.
Sweep step checks `heap_pages_freeable_pages`, so compaction should do the same.
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/gc.c b/gc.c
index 66bdb012b6..18154714db 100644
--- a/gc.c
+++ b/gc.c
@@ -8409,10 +8409,12 @@ gc_compact_after_gc(rb_objspace_t *objspace, int use_toward_empty, int use_doubl
RMOVED(moved_list)->next = 0;
page->free_slots++;
heap_page_add_freeobj(objspace, page, moved_list);
- if (page->free_slots == page->total_slots) {
+ if (page->free_slots == page->total_slots && heap_pages_freeable_pages > 0) {
heap_pages_freeable_pages--;
heap_unlink_page(objspace, heap_eden, page);
heap_add_page(objspace, heap_tomb, page);
+ } else if (page->free_slots == page->total_slots) {
+ page->free_next = NULL;
}
objspace->profile.total_freed_objects++;
moved_list = next_moved;