Skip to content

[GC API] Change implementation of objects freed at shutdown to use heap walking #87

Open
@peterzhu2118

Description

@peterzhu2118

Right now, we place objects that need to be freed at shutdown into a weak list that is traversed at shutdown. This makes allocation slower and increases memory used.

Allocation:

ruby/gc/mmtk.c

Line 224 in 9903af4

mmtk_add_obj_free_candidate(alloc_obj);

Shutdown:

ruby/gc/mmtk.c

Lines 495 to 503 in 9903af4

struct MMTk_RawVecOfObjRef registered_candidates = mmtk_get_all_obj_free_candidates();
for (size_t i = 0; i < registered_candidates.len; i++) {
VALUE obj = (VALUE)registered_candidates.ptr[i];
if (rb_gc_shutdown_call_finalizer_p(obj)) {
rb_gc_obj_free(objspace_ptr, obj);
}
}
mmtk_free_raw_vec_of_obj_ref(registered_candidates);

Instead, we should use heap walking at shutdown to free these objects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions