From: "Слепнев Владимир" Date: 2004-05-12T03:28:09+09:00 Subject: memory leak when using continuations+weakrefs? Hello, the following code eats up more and more memory as it works, pretty fast. It shouldn't. require 'weakref' class A attr_accessor :child def foo @child = B.new @child.call end end class B def call callcc do |cc| @cont = cc end end def answer(obj) @cont.call(obj) end end def purge(array) array.delete_if {|x| not x.weakref_alive?} end a = A.new arr = [] loop { a.foo; arr << WeakRef.new(a.child); purge(arr)} If we comment out the line @cont = cc, the leak goes away. If we don't save weakrefs at all, the leak also goes away. I don't understand it. This combination (weakrefs + continuations) is not contrived: it is used in the Borges web framework, for an important purpose. Vladimir Slepnev