@@ -4262,8 +4262,6 @@ objspace_allrefs(rb_objspace_t *objspace)
4262
4262
struct mark_func_data_struct mfd ;
4263
4263
VALUE obj ;
4264
4264
4265
- rb_gc_disable ();
4266
-
4267
4265
data .objspace = objspace ;
4268
4266
data .references = st_init_numtable ();
4269
4267
@@ -4281,7 +4279,6 @@ objspace_allrefs(rb_objspace_t *objspace)
4281
4279
}
4282
4280
shrink_stack_chunk_cache (& objspace -> mark_stack );
4283
4281
4284
- rb_gc_enable ();
4285
4282
return data .references ;
4286
4283
}
4287
4284
@@ -4379,8 +4376,14 @@ gc_check_after_marks_i(st_data_t k, st_data_t v, void *ptr)
4379
4376
static void
4380
4377
gc_marks_check (rb_objspace_t * objspace , int (* checker_func )(ANYARGS ), const char * checker_name )
4381
4378
{
4382
- objspace -> rgengc .allrefs_table = objspace_allrefs (objspace );
4379
+
4380
+ size_t saved_malloc_increase = objspace -> malloc_params .increase ;
4381
+ #if RGENGC_ESTIMATE_OLDMALLOC
4382
+ size_t saved_oldmalloc_increase = objspace -> rgengc .oldmalloc_increase ;
4383
+ #endif
4384
+ VALUE already_disabled = rb_gc_disable ();
4383
4385
4386
+ objspace -> rgengc .allrefs_table = objspace_allrefs (objspace );
4384
4387
st_foreach (objspace -> rgengc .allrefs_table , checker_func , (st_data_t )objspace );
4385
4388
4386
4389
if (objspace -> rgengc .error_count > 0 ) {
@@ -4392,6 +4395,12 @@ gc_marks_check(rb_objspace_t *objspace, int (*checker_func)(ANYARGS), const char
4392
4395
4393
4396
objspace_allrefs_destruct (objspace -> rgengc .allrefs_table );
4394
4397
objspace -> rgengc .allrefs_table = 0 ;
4398
+
4399
+ if (already_disabled == Qfalse ) rb_gc_enable ();
4400
+ objspace -> malloc_params .increase = saved_malloc_increase ;
4401
+ #if RGENGC_ESTIMATE_OLDMALLOC
4402
+ objspace -> rgengc .oldmalloc_increase = saved_oldmalloc_increase ;
4403
+ #endif
4395
4404
}
4396
4405
4397
4406
#endif /* RGENGC_CHECK_MODE >= 2 */
0 commit comments