Skip to content

Instantly share code, notes, and snippets.

@chechaoyang
Created July 27, 2012 04:31
Show Gist options
  • Save chechaoyang/3186186 to your computer and use it in GitHub Desktop.
Save chechaoyang/3186186 to your computer and use it in GitHub Desktop.
Ruby Symbol Garbage Collection
1.9.3p194 :005 > hash = { test_symbol_gc: "test" }
=> {:test_symbol_gc=>"test"}
1.9.3p194 :006 > Symbol.all_symbols.find { |s| s.to_s == "test_symbol_gc" }
=> :test_symbol_gc
1.9.3p194 :007 > hash = nil
=> nil
1.9.3p194 :008 > GC.start
=> nil
1.9.3p194 :009 > Symbol.all_symbols.find { |s| s.to_s == "test_symbol_gc" }
=> :test_symbol_gc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment