Guest User

Untitled

a guest
Jun 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. def make_hash
  2. h = {}
  3. 5000.times { |i| h[:"key_#{i}"] = WeakRef.new("value_#{i}") }
  4. h
  5. end
  6.  
  7. h = make_hash
  8. puts "Checking reference is alive"
  9. p h[:key_200].weakref_alive?
  10.  
  11. puts "Running GC"
  12. GC.run(true)
  13.  
  14. puts "Checking reference is alive"
  15. p h[:key_200].weakref_alive?
Add Comment
Please, Sign In to add comment