summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2013-11-22 09:20:06 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2013-11-22 09:20:06 +0900
commit07b8a5b0427c21518c7b7cf465197dc310b9d3b0 (patch)
treebb55a8c8595ed5b8bc95a6792e0d218014c2f4c9 /include
parentb723f67b8b271ee2ace40db723d8eeff5a70f270 (diff)
downloadmruby-07b8a5b0427c21518c7b7cf465197dc310b9d3b0.tar.gz
mruby-07b8a5b0427c21518c7b7cf465197dc310b9d3b0.zip
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.
Diffstat (limited to 'include')
-rw-r--r--include/mrbconf.h6
-rw-r--r--include/mruby.h11
2 files changed, 14 insertions, 3 deletions
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 */