Merge pull request #5763 from dearblue/realloc-fullgc

Perform Full-GC from `mrb_realloc_simple()` by `MRB_GC_STRESS + MRB_DEBUG`
This commit is contained in:
Yukihiro "Matz" Matsumoto
2022-08-09 14:00:18 +09:00
committed by GitHub
2 changed files with 9 additions and 0 deletions
+2
View File
@@ -82,6 +82,8 @@ You can use mrbconfs with following ways:
* When defined full GC is emitted per each `RBasic` allocation.
* Mainly used in memory manager debugging.
* If defined at the same time as `MRB_DEBUG`, full GC is emitted also per each heap allocation (`mrb_malloc()` or etc.).
This configuration slows down mruby execution by a factor of 2 to 3 or even more.
`MRB_GC_TURN_OFF_GENERATIONAL`
+7
View File
@@ -224,6 +224,9 @@ mrb_realloc_simple(mrb_state *mrb, void *p, size_t len)
{
void *p2;
#if defined(MRB_GC_STRESS) && defined(MRB_DEBUG)
mrb_full_gc(mrb);
#endif
p2 = (mrb->allocf)(mrb, p, len, mrb->allocf_ud);
if (!p2 && len > 0 && mrb->gc.heaps) {
mrb_full_gc(mrb);
@@ -921,6 +924,10 @@ obj_free(mrb_state *mrb, struct RBasic *obj, int end)
default:
break;
}
#if defined(MRB_GC_STRESS) && defined(MRB_DEBUG)
memset(obj, -1, sizeof(RVALUE));
paint_white(obj);
#endif
obj->tt = MRB_TT_FREE;
}