Created
April 5, 2015 10:01
-
-
Save niamster/862acd8a0c2561940ffc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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