Continuations and GC


#1

I have problems getting things GC:ed properly when using
continuations, which is a bit disturbing.

I was looking at a few implementations of coroutines and they seem to
prevent their continuations from being gc:ed.
For example, I looked at this implementation:

http://onestepback.org/articles/invitationtoruby/coroutinedemo.html

Altering the end of this demo to do:

first.start
first = nil
second = nil
garbage_collect
ObjectSpace.each_object(Continuation) {|x| puts x }

Gave me a list of all the continuations spawned by the two
coroutines. Apparently they had yet to be GC:ed. Another
implementation seemed to be similarly flawed.

Is there a way to make this work or perhaps my understanding of the
GC is flawed?

Sincerly,

Christoffer