Created
March 27, 2017 22:16
-
-
Save ehrenmurdick/da403747f902c8d113ac3252593b543c to your computer and use it in GitHub Desktop.
closure memory leak in ruby
This file contains hidden or 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
N = 10_000_000 | |
class Foo | |
def initialize | |
@ary = (0..N).map { Object.new } | |
end | |
def a | |
return proc do | |
"hello" | |
end | |
end | |
end | |
def wat | |
Foo.new.a | |
end | |
cl = wat | |
GC.start | |
puts "sleeping" | |
sleep 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment