Skip to content

Commit

Permalink
Iterate and free all MMTK objects at shutdown
Browse files Browse the repository at this point in the history
If requested using RUBY_FREE_AT_EXIT
  • Loading branch information
eightbitraptor committed Oct 21, 2024
1 parent 6cb5721 commit 4e988e6
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion gc/mmtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,25 @@ rb_gc_impl_heap_sizes(void *objspace_ptr)
return heap_sizes;
}

int
rb_mmtk_obj_free_iter_wrapper(VALUE obj, void *data)
{
struct objspace *objspace = data;

if (RB_BUILTIN_TYPE(obj) != T_NONE) {
rb_gc_obj_free_vm_weak_references(obj);
rb_gc_obj_free(objspace, obj);
}

return 0;
}

// Shutdown
void rb_gc_impl_shutdown_free_objects(void *objspace_ptr) { }
static void each_object(struct objspace *objspace, int (*func)(VALUE, void *), void *data);

void rb_gc_impl_shutdown_free_objects(void *objspace_ptr) {
each_object(objspace_ptr, rb_mmtk_obj_free_iter_wrapper, objspace_ptr);
}

// GC
void
Expand Down

0 comments on commit 4e988e6

Please sign in to comment.