From 07b8a5b0427c21518c7b7cf465197dc310b9d3b0 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 22 Nov 2013 09:20:06 +0900 Subject: Make mrb->arena variable sized. Use MRB_GC_FIXED_ARENA for old behavior. You will not see "arena overflow" error anymore, but I encourage gem authors to check your gems with MRB_GC_FIXED_ARENA to avoid memory broat. --- include/mrbconf.h | 6 ++++++ include/mruby.h | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/mrbconf.h b/include/mrbconf.h index a10a1d04e..5c745f479 100644 --- a/include/mrbconf.h +++ b/include/mrbconf.h @@ -59,6 +59,12 @@ /* array size for parser buffer */ //#define MRB_PARSER_BUF_SIZE 1024 +/* arena size */ +//#define MRB_GC_ARENA_SIZE 100 + +/* fixed size GC arena */ +//#define MRB_GC_FIXED_ARENA + /* -DDISABLE_XXXX to drop following features */ //#define DISABLE_STDIO /* use of stdio */ diff --git a/include/mruby.h b/include/mruby.h index e70487f27..882ba4e07 100644 --- a/include/mruby.h +++ b/include/mruby.h @@ -46,8 +46,8 @@ struct mrb_state; typedef void* (*mrb_allocf) (struct mrb_state *mrb, void*, size_t, void *ud); -#ifndef MRB_ARENA_SIZE -#define MRB_ARENA_SIZE 100 +#ifndef MRB_GC_ARENA_SIZE +#define MRB_GC_ARENA_SIZE 100 #endif typedef struct { @@ -128,7 +128,12 @@ typedef struct mrb_state { struct heap_page *sweeps; struct heap_page *free_heaps; size_t live; /* count of live objects */ - struct RBasic *arena[MRB_ARENA_SIZE]; /* GC protection array */ +#ifdef MRB_GC_FIXED_ARENA + struct RBasic *arena[MRB_GC_ARENA_SIZE]; /* GC protection array */ +#else + struct RBasic **arena; /* GC protection array */ + int arena_capa; +#endif int arena_idx; enum gc_state gc_state; /* state of gc */ -- cgit v1.2.3