Don't allocate objects in gc_compact
I'd like to call `gc_compact` after major GC, but before the GC finishes. This means we can't allocate any objects inside `gc_compact`. So in this commit I'm just pulling the compaction statistics allocation outside the `gc_compact` function so we can safely call it.
This commit is contained in:
parent
cbf88064f5
commit
a20ed0565e
9
gc.c
9
gc.c
@ -8279,7 +8279,7 @@ gc_compact_stats(rb_objspace_t *objspace)
|
|||||||
|
|
||||||
static void gc_compact_after_gc(rb_objspace_t *objspace, int use_toward_empty, int use_double_pages, int use_verifier);
|
static void gc_compact_after_gc(rb_objspace_t *objspace, int use_toward_empty, int use_double_pages, int use_verifier);
|
||||||
|
|
||||||
static VALUE
|
static void
|
||||||
gc_compact(rb_objspace_t *objspace, int use_toward_empty, int use_double_pages, int use_verifier)
|
gc_compact(rb_objspace_t *objspace, int use_toward_empty, int use_double_pages, int use_verifier)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -8291,7 +8291,6 @@ gc_compact(rb_objspace_t *objspace, int use_toward_empty, int use_double_pages,
|
|||||||
gc_compact_after_gc(objspace, use_toward_empty, use_double_pages, TRUE);
|
gc_compact_after_gc(objspace, use_toward_empty, use_double_pages, TRUE);
|
||||||
}
|
}
|
||||||
objspace->flags.during_compacting = FALSE;
|
objspace->flags.during_compacting = FALSE;
|
||||||
return gc_compact_stats(objspace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -8300,7 +8299,8 @@ rb_gc_compact(VALUE mod)
|
|||||||
rb_objspace_t *objspace = &rb_objspace;
|
rb_objspace_t *objspace = &rb_objspace;
|
||||||
if (dont_gc) return Qnil;
|
if (dont_gc) return Qnil;
|
||||||
|
|
||||||
return gc_compact(objspace, FALSE, FALSE, FALSE);
|
gc_compact(objspace, FALSE, FALSE, FALSE);
|
||||||
|
return gc_compact_stats(objspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -8465,7 +8465,8 @@ gc_verify_compaction_references(int argc, VALUE *argv, VALUE mod)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return gc_compact(objspace, use_toward_empty, use_double_pages, TRUE);
|
gc_compact(objspace, use_toward_empty, use_double_pages, TRUE);
|
||||||
|
return gc_compact_stats(objspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user