Skip to content

Instantly share code, notes, and snippets.

@aergonaut
Created July 22, 2021 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aergonaut/bc615231884c232a520f23e76d6ac1c3 to your computer and use it in GitHub Desktop.
Save aergonaut/bc615231884c232a520f23e76d6ac1c3 to your computer and use it in GitHub Desktop.
GC.start
before = GC.stat(:total_freed_objects)
100_000.times do
foo = "a string"
end
GC.start
after = GC.stat(:total_freed_objects)
puts "(Creating Strings) Objects Freed: #{after - before}"
GC.start
before = GC.stat(:total_freed_objects)
foo = "a string"
100_000.times do
bar = foo.to_sym
end
GC.start
after = GC.stat(:total_freed_objects)
puts "(Calling to_sym) Objects Freed: #{after - before}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment