-
Notifications
You must be signed in to change notification settings - Fork 419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak in Concurrent::Future #959
Comments
It turns out that there is way more leaking than just the return value of the block: # frozen_string_literal: true
require 'bundler/inline'
gemfile(true) do
source 'https://rubygems.org'
gem 'concurrent-ruby', '1.1.10'
gem 'memory_profiler', '~> 1'
end
class Thing; end
def report(title, &block)
puts title
pp MemoryProfiler.report(&block).retained_memory_by_class
end
report('Warmup') do
Concurrent::Future.execute { Thing.new }.wait
end
report('When waiting for the Future') do
Concurrent::Future.execute { Thing.new }.wait
end
report('When waiting for the Future and actively dereferencing it') do
x = Concurrent::Future.execute { Thing.new }.wait
x = nil
end yields the output:
|
Maybe this "leaking" of the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When passing a
block
toConcurrent::Future.execute
andwait
ing for the result, theFuture
can be garbage collected, but the return value of the block seems to stay in memory forever, as demonstrated by the following script:When running the script on several different versions of MRI, I always get something like this never ending output:
The text was updated successfully, but these errors were encountered: