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

Fiber context leakage #3109

Closed
tsahara opened this Issue Feb 16, 2016 · 0 comments

Comments

Projects
None yet
1 participant
@tsahara
Member

tsahara commented Feb 16, 2016

Creating many Fiber objects (then freeing them by GC) causes memory leakage:

% cat f.rb
100.times { |n|
  10000.times { |i|
    f = Fiber.new {}
    f.resume
  }
  puts n
}

% bin/mruby f.rb
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
trace:
        [4] f.rb:3:in Object.call
        [3] /home/tsahara/src/mruby/mrblib/numeric.rb:77:in Integral#times
        [2] f.rb:2:in Object.call
        [1] /home/tsahara/src/mruby/mrblib/numeric.rb:77:in Integral#times
        [0] f.rb:1
RuntimeError: Out of memory
zsh: segmentation fault (core dumped)  bin/mruby f.rb

I found that Fiber's contexts (f->cxt) were freed in obj_free before the commit 3531fe1 and the commit removes mrb_free_context() call (but I don't know how to free Fiber objects correctly...).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment