Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Created February 1, 2021 20:43
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 tenderlove/3796921853fe1f2369bc56482eceb53e to your computer and use it in GitHub Desktop.
Save tenderlove/3796921853fe1f2369bc56482eceb53e to your computer and use it in GitHub Desktop.
require "objspace"
require "json"
def go x
count = GC.stat(:major_gc_count)
loop do
info = JSON.parse(ObjectSpace.dump(x))
break if info["flags"]["old"]
GC.start
end
GC.stat(:major_gc_count) - count
end
p go(Object.new)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment