Skip to content

Instantly share code, notes, and snippets.

@al2o3cr
Created November 2, 2010 21:18
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 al2o3cr/660316 to your computer and use it in GitHub Desktop.
Save al2o3cr/660316 to your computer and use it in GitHub Desktop.
GC.start
first_count = ObjectSpace.each_object(String) { |x| nil }
def dummy_function
'foo'
end
second_count = ObjectSpace.each_object(String) { |x| nil }
GC.start
second_after_gc_count = ObjectSpace.each_object(String) { |x| nil }
dummy_function;
third_count = ObjectSpace.each_object(String) { |x| nil }
GC.start
third_after_gc_count = ObjectSpace.each_object(String) { |x| nil }
dummy_function;
fourth_count = ObjectSpace.each_object(String) { |x| nil }
GC.start
fourth_after_gc_count = ObjectSpace.each_object(String) { |x| nil }
puts "#{first_count} #{second_count} #{second_after_gc_count} #{third_count} #{third_after_gc_count} #{fourth_count} #{fourth_after_gc_count}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment