# Continuations and GC

**URL:** <https://www.ruby-forum.com/t/continuations-and-gc/101244>\
**Category:** Ruby\
**Created:** [February 5, 2006, 12:15pm UTC](https://www.ruby-forum.com/t/continuations-and-gc/101244 "2006-02-05T12:15:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christoffer\_LernSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@Christoffer\_LernSSS](https://www.ruby-forum.com/u/Christoffer_LernSSS)\
**Post date:** [February 5, 2006, 12:15pm UTC](https://www.ruby-forum.com/t/continuations-and-gc/101244/1 "2006-02-05T12:15:49Z")

</div>

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](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
