summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-18 07:29:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-18 07:29:17 +0000
commitd36c76dc71b47b201707185b8a0b4264e83de205 (patch)
treedf6b3edc1d6715dd11be75675f5ec55c54d3fa11 /gc.c
parent868684096079f3e786df517714fe6d795c4647b6 (diff)
* common.mk (eval.o): needs vm.h.
* eval.c (ruby_cleanup): destruct current VM before exit. * gc.c (rb_objspace_free): free object space. * vm.c (ruby_vm_destruct): destruct and free VM struct. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/gc.c b/gc.c
index 6469e98b58..a7f92806ae 100644
--- a/gc.c
+++ b/gc.c
@@ -366,6 +366,8 @@ int *ruby_initial_gc_stress_ptr = &rb_objspace.gc_stress;
#define need_call_final (finalizer_table && finalizer_table->num_entries)
+static void rb_objspace_call_finalizer(rb_objspace_t *objspace);
+
#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
rb_objspace_t *
rb_objspace_alloc(void)
@@ -377,6 +379,33 @@ rb_objspace_alloc(void)
return objspace;
}
+
+void
+rb_objspace_free(rb_objspace_t *objspace)
+{
+ rb_objspace_call_finalizer(objspace);
+ if (objspace->profile.record) {
+ free(objspace->profile.record);
+ objspace->profile.record = 0;
+ }
+ if (global_List) {
+ struct gc_list *list, *next;
+ for (list = global_List; list; list = next) {
+ next = list->next;
+ free(list);
+ }
+ }
+ if (heaps) {
+ int i;
+ for (i = 0; i < heaps_used; ++i) {
+ free(heaps[i].membase);
+ }
+ free(heaps);
+ heaps_used = 0;
+ heaps = 0;
+ }
+ free(objspace);
+}
#endif
/* tiny heap size */
@@ -2613,7 +2642,12 @@ chain_finalized_object(st_data_t key, st_data_t val, st_data_t arg)
void
rb_gc_call_finalizer_at_exit(void)
{
- rb_objspace_t *objspace = &rb_objspace;
+ rb_objspace_call_finalizer(&rb_objspace);
+}
+
+void
+rb_objspace_call_finalizer(rb_objspace_t *objspace)
+{
RVALUE *p, *pend;
RVALUE *final_list = 0;
size_t i;