Permalink
Browse files

free heap pages from mrb_close()

  • Loading branch information...
1 parent 3762669 commit d04a7ec632731f81c7230af1c6fbb260d3742d33 @matz matz committed Aug 27, 2012
Showing with 15 additions and 0 deletions.
  1. +13 −0 src/gc.c
  2. +2 −0 src/state.c
View
@@ -284,6 +284,19 @@ mrb_init_heap(mrb_state *mrb)
#endif
}
+void
+mrb_free_heap(mrb_state *mrb)
+{
+ struct heap_page *page = mrb->heaps;
+ struct heap_page *tmp;
+
+ while (page) {
+ tmp = page;
+ page = page->next;
+ mrb_free(mrb, tmp);
+ }
+}
+
static void
gc_protect(mrb_state *mrb, struct RBasic *p)
{
View
@@ -51,6 +51,7 @@ mrb_open()
}
void mrb_free_symtbl(mrb_state *mrb);
+void mrb_free_heap(mrb_state *mrb);
void
mrb_close(mrb_state *mrb)
@@ -72,6 +73,7 @@ mrb_close(mrb_state *mrb)
}
mrb_free(mrb, mrb->irep);
mrb_free_symtbl(mrb);
+ mrb_free_heap(mrb);
mrb_free(mrb, mrb);
}

0 comments on commit d04a7ec

Please sign in to comment.