diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-18 07:29:17 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-18 07:29:17 +0000 |
commit | d482ac18c5cb70a3f888f335cd9a32b196a558bc (patch) | |
tree | df6b3edc1d6715dd11be75675f5ec55c54d3fa11 /gc.c | |
parent | 1a1fb4309ac4ad58c9fb169d775f813c395f53fb (diff) | |
download | ruby-d482ac18c5cb70a3f888f335cd9a32b196a558bc.tar.gz ruby-d482ac18c5cb70a3f888f335cd9a32b196a558bc.tar.xz ruby-d482ac18c5cb70a3f888f335cd9a32b196a558bc.zip |
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@25000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 36 |
1 files changed, 35 insertions, 1 deletions
@@ -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; |