我在使用MRuby代码救援时收到此错误:
arena overflow error
我不熟悉这个术语以及如何解决它。以下是我的C程序示例:
while (true) {
SDL_Event event;
if (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) break; //exit the loop
switch(event.type) {
case SDL_KEYDOWN:
if (event.key.keysym.sym == SDLK_LEFT) { key = "left"; code = "input_received(:left)"; }
//...
printf("Key down: %s\n", key);
mrb_load_string(mrb, code);
break;
}
}
// Re-render each iteration
mrb_load_string(mrb, "render()"); //<-- this is the line that causes the error
}
答案 0 :(得分:0)
使用mrb_gc_arena_save / mrb_gc_arena_restore阻止分配临时对象的代码。
int ai = mrb_gc_arena_save(mrb);
// creating temporary objects
mrb_gc_arena_restore(mrb, ai);