-
-
Save radiospiel/6c7fddbacc65c088bc79 to your computer and use it in GitHub Desktop.
Crystal GC troubles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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