diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-05-19 17:34:56 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-05-19 17:34:56 +0900 |
| commit | 82194c01ca4be9b7f903022621ab3ef0f61b137d (patch) | |
| tree | fa7e7455b255a1ecd8abc9835d2b1f68644e1480 /include | |
| parent | 3655d4e0f486762628c0fd190a36a6199d898f29 (diff) | |
| parent | 69bc477b434b6d1ac990178ca0e3cfbbf28b90d9 (diff) | |
| download | mruby-82194c01ca4be9b7f903022621ab3ef0f61b137d.tar.gz mruby-82194c01ca4be9b7f903022621ab3ef0f61b137d.zip | |
Merge pull request #5002 from RoryO/master
Adding warnings for mrb_load functions leaking RProc objects
Diffstat (limited to 'include')
| -rw-r--r-- | include/mruby/compile.h | 10 | ||||
| -rw-r--r-- | include/mruby/irep.h | 10 |
2 files changed, 19 insertions, 1 deletions
diff --git a/include/mruby/compile.h b/include/mruby/compile.h index 69dfd1d50..5e73e66a6 100644 --- a/include/mruby/compile.h +++ b/include/mruby/compile.h @@ -180,7 +180,15 @@ MRB_API struct mrb_parser_state* mrb_parse_nstring(mrb_state*,const char*,size_t MRB_API struct RProc* mrb_generate_code(mrb_state*, struct mrb_parser_state*); MRB_API mrb_value mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c); -/* program load functions */ +/** program load functions +* Please note! Currently due to interactions with the GC calling these functions will +* leak one RProc object per function call. +* To prevent this save the current memory arena before calling and restore the arena +* right after, like so +* int ai = mrb_gc_arena_save(mrb); +* mrb_value status = mrb_load_string(mrb, buffer); +* mrb_gc_arena_restore(mrb, ai); +*/ #ifndef MRB_DISABLE_STDIO MRB_API mrb_value mrb_load_file(mrb_state*,FILE*); MRB_API mrb_value mrb_load_file_cxt(mrb_state*,FILE*, mrbc_context *cxt); diff --git a/include/mruby/irep.h b/include/mruby/irep.h index 4393129c7..661ef2b48 100644 --- a/include/mruby/irep.h +++ b/include/mruby/irep.h @@ -49,6 +49,16 @@ typedef struct mrb_irep { MRB_API mrb_irep *mrb_add_irep(mrb_state *mrb); +/** load mruby bytecode functions +* Please note! Currently due to interactions with the GC calling these functions will +* leak one RProc object per function call. +* To prevent this save the current memory arena before calling and restore the arena +* right after, like so +* int ai = mrb_gc_arena_save(mrb); +* mrb_value status = mrb_load_irep(mrb, buffer); +* mrb_gc_arena_restore(mrb, ai); +*/ + /* @param [const uint8_t*] irep code, expected as a literal */ MRB_API mrb_value mrb_load_irep(mrb_state*, const uint8_t*); |
