From 69465df4242f3b2d8e55fbe18d7c45b47b40a626 Mon Sep 17 00:00:00 2001 From: HParker Date: Fri, 17 Feb 2023 08:15:03 -0800 Subject: Allow classes and modules to become too complex This makes the behavior of classes and modules when there are too many instance variables match the behavior of objects with too many instance variables. --- gc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'gc.c') diff --git a/gc.c b/gc.c index b8c8ae099d..bbcdc4cedc 100644 --- a/gc.c +++ b/gc.c @@ -3558,7 +3558,11 @@ obj_free(rb_objspace_t *objspace, VALUE obj) case T_CLASS: rb_id_table_free(RCLASS_M_TBL(obj)); cc_table_free(objspace, obj, FALSE); - if (RCLASS_IVPTR(obj)) { + if (rb_shape_obj_too_complex(obj)) { + RB_DEBUG_COUNTER_INC(obj_obj_too_complex); + rb_id_table_free(RCLASS_TABLE_IVPTR(obj)); + } + else if (RCLASS_IVPTR(obj)) { xfree(RCLASS_IVPTR(obj)); } if (RCLASS_CONST_TBL(obj)) { -- cgit v1.2.3