public
Created

weakref behavior

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
This is from the end of weakref.rb:
 
if __FILE__ == $0
# require 'thread'
foo = Object.new
p foo.to_s # original's class
foo = WeakRef.new(foo)
p foo.to_s # should be same class
ObjectSpace.garbage_collect
ObjectSpace.garbage_collect
p foo.to_s # should raise exception (recycled)
end
 
And this is the output from running it (no exception raised):
 
"#<Object:0x000001010b3ea0>"
"#<Object:0x000001010b3ea0>"
"#<Object:0x000001010b3ea0>"
 
Any thoughts on why? I haven't yet delved deeply into the code.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.