Skip to content

Instantly share code, notes, and snippets.

@niamster
Created April 5, 2015 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niamster/862acd8a0c2561940ffc to your computer and use it in GitHub Desktop.
Save niamster/862acd8a0c2561940ffc to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'weakref'
foo = 'toto'
weak = WeakRef.new foo
f = Fiber.new do
p foo
# if fiber yield is not called the fiber context is never released
# Fiber.yield
end
f.resume
f = nil
foo = nil
puts 'Wait'
bars = []
loop do
GC.start
break unless weak.weakref_alive?
bars << 'toto'
end
puts 'PASS' unless weak.weakref_alive?
sleep 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment