From: "ara.t.howard" Date: 2008-09-18T03:41:37+09:00 Subject: Re: Threads preventing garbage collection? On Sep 17, 2008, at 10:21 AM, Brian Candler wrote: > Ara Howard wrote: >> but that it expected? you have a Foo which referes to a Thread which >> has not died that is itself referred to by the global Thread.list >> >> cfp:~ > ruby -e' 41.times{ Thread.new{ sleep } }; p >> Thread.list.size ' >> 42 > > Foo ------------> > thread > thread list ----> > > I don't think this should prevent garbage collection of Foo, if > nothing > is holding a reference to Foo > -- > Posted via http://www.ruby-forum.com/. > but threads *do* hold their context void rb_thread_schedule(void) { thread_debug("rb_thread_schedule\n"); if (!rb_thread_alone()) { rb_thread_t *th = GET_THREAD(); thread_debug("rb_thread_schedule/switch start\n"); rb_gc_save_machine_context (th); // <-- global state native_mutex_unlock(&th->vm->global_interpreter_lock); { native_thread_yield(); } native_mutex_lock(&th->vm->global_interpreter_lock); rb_thread_set_current(th); thread_debug("rb_thread_schedule/switch done\n"); RUBY_VM_CHECK_INTS(); } } a @ http://codeforpeople.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama