Skip to content

Instantly share code, notes, and snippets.

@ehrenmurdick
Created March 27, 2017 22:16
Show Gist options
  • Save ehrenmurdick/da403747f902c8d113ac3252593b543c to your computer and use it in GitHub Desktop.
Save ehrenmurdick/da403747f902c8d113ac3252593b543c to your computer and use it in GitHub Desktop.
closure memory leak in ruby
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