Skip to content

Instantly share code, notes, and snippets.

@radiospiel
Last active March 16, 2016 14:39
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 radiospiel/6c7fddbacc65c088bc79 to your computer and use it in GitHub Desktop.
Save radiospiel/6c7fddbacc65c088bc79 to your computer and use it in GitHub Desktop.
Crystal GC troubles
# r.cr
#
# This results in
#
# ~> crystal r.cr
# GC Warning: Finalization cycle involving 0x10424fe00
#
# No finalizer has been called.
#
class Parent
def add_child; @child = Child.new(self); end
def finalize; puts "finalize Parent"; end
end
class Child
def initialize(@parent); end
def finalize; puts "finalize Child"; end
end
def f(cnt)
(0...cnt).each do
p = Parent.new
p.add_child
end
end
f(1)
GC.collect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment