Skip to content

Instantly share code, notes, and snippets.

@yhara
Last active February 16, 2019 10:35
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 yhara/502e351332d893cd020466d28d373ac0 to your computer and use it in GitHub Desktop.
Save yhara/502e351332d893cd020466d28d373ac0 to your computer and use it in GitHub Desktop.
HOOK = proc{}
class A
def foo
ObjectSpace.define_finalizer self, HOOK
end
end
A.new.foo
10.times{GC.start}
p ObjectSpace.each_object(A).to_a #=> [#<A:0x00007fbae28ef1f8>]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment