Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def make_hash
- h = {}
- 5000.times { |i| h[:"key_#{i}"] = WeakRef.new("value_#{i}") }
- h
- end
- h = make_hash
- puts "Checking reference is alive"
- p h[:key_200].weakref_alive?
- puts "Running GC"
- GC.run(true)
- puts "Checking reference is alive"
- p h[:key_200].weakref_alive?
Add Comment
Please, Sign In to add comment