Skip to content

Commit

Permalink
GC.free_all_empty_pages take a compact parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Oct 9, 2023
1 parent 8460e0c commit d994dcb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9849,12 +9849,19 @@ gc_start_internal(rb_execution_context_t *ec, VALUE self, VALUE full_mark, VALUE
}

static VALUE
free_all_empty_pages(VALUE self)
free_all_empty_pages(int argc, VALUE *argv, VALUE self)
{
rb_objspace_t *objspace = &rb_objspace;

VALUE compact = Qfalse;

rb_check_arity(argc, 0, 1);
if (argc > 0) {
compact = argv[0];
}

objspace->flags.free_all_empty_pages = 1;
gc_start_internal(NULL, self, Qtrue, Qtrue, Qtrue, Qfalse);
gc_start_internal(NULL, self, Qtrue, Qtrue, Qtrue, compact);
objspace->flags.free_all_empty_pages = 0;

return Qnil;
Expand Down Expand Up @@ -14697,7 +14704,7 @@ Init_GC(void)
rb_define_singleton_method(rb_mGC, "malloc_allocated_size", gc_malloc_allocated_size, 0);
rb_define_singleton_method(rb_mGC, "malloc_allocations", gc_malloc_allocations, 0);
#endif
rb_define_singleton_method(rb_mGC, "free_all_empty_pages", free_all_empty_pages, 0);
rb_define_singleton_method(rb_mGC, "free_all_empty_pages", free_all_empty_pages, -1);

rb_define_singleton_method(rb_mGC, "using_rvargc?", gc_using_rvargc_p, 0);

Expand Down

0 comments on commit d994dcb

Please sign in to comment.