Memory leak in Concurrent::Promises.future

Abierto
#960 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
38/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
ruby

Línea de trabajo

Start at Concurrent::Promises.future and reproduce the report with the supplied Ruby script and concurrent-ruby 1.1.10. Trace retained objects around each future and wait call; done means the reported memory retention is resolved without changing the non-leaking return-value behavior noted in the issue.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

* Operating system:                linux
* Ruby implementation:             Ruby
* `concurrent-ruby` version:       1.1.10
* `concurrent-ruby-ext` installed: no
* `concurrent-ruby-edge` used:     no

The test script

# 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::Promises.future { Thing.new }.wait
end

report('When waiting for the Future') do
  Concurrent::Promises.future { Thing.new }.wait
end

report('When waiting for the Future with args') do
  Concurrent::Promises.future(Thing.new) { |o| o }.wait
end

report('When waiting for the Future and actively dereferencing it') do
  x = Concurrent::Promises.future { Thing.new }.wait
  x = nil
end

report('When waiting for the Future with args and actively dereferencing it') do
  x = Concurrent::Promises.future(Thing.new) { |o| o }.wait
  x = nil
end

yields the following output

Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using bundler 2.3.19
Using memory_profiler 1.0.0
Using concurrent-ruby 1.1.10
Warmup
[{:data=>"Thread", :count=>1048992},
 {:data=>"Concurrent::CachedThreadPool", :count=>216},
 {:data=>"Thread::Mutex", :count=>216},
 {:data=>"Array", :count=>200},
 {:data=>"Thread::ConditionVariable", :count=>192},
 {:data=>"Concurrent::Event", :count=>144},
 {:data=>"Proc", :count=>80},
 {:data=>"String", :count=>80},
 {:data=>"Thread::Queue", :count=>76},
 {:data=>"Concurrent::RubyThreadPoolExecutor::Worker", :count=>40}]
When waiting for the Future
[{:data=>"Array", :count=>40}]
When waiting for the Future with args
[{:data=>"Array", :count=>40}]
When waiting for the Future and actively dereferencing it
[{:data=>"Array", :count=>40}]
When waiting for the Future with args and actively dereferencing it
[{:data=>"Array", :count=>40}]

Note that in contrast to #959 the return value of the block is not leaking here.

Lenguaje dominante
Ruby
Estrellas
5.8k
Forks
420
Merge medio
20 h 45 min
PR fusionados (30 d)
4

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de ruby-concurrency/concurrent-ruby

Todos los issues de ruby-concurrency/concurrent-ruby

Issues similares

Más issues de Ruby

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.