Perform Full-GC from mrb_realloc_simple() by MRB_GC_STRESS + MRB_DEBUG

It also fills the GC'ed object area with `0xff` for debugging purposes.
This commit is contained in:
dearblue
2022-07-30 22:31:57 +09:00
parent a0c02e0a64
commit 71c398f298
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;
}