From: Robert Pankowecki Date: 2011-10-12T22:06:45+09:00 Subject: [ruby-core:40117] [Ruby 1.9 - Bug #5437][Open] Using fibers leads to huge memory leak Issue #5437 has been reported by Robert Pankowecki. ---------------------------------------- Bug #5437: Using fibers leads to huge memory leak http://redmine.ruby-lang.org/issues/5437 Author: Robert Pankowecki Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 1.9.3dev (2011-10-11 revision 33457) [x86_64-linux] It appears to me that there is something wrong with reallocating (reusing?) memory used by fibers. Here is a little script: require 'fiber' fibers = 10_000.times.map do Fiber.new do f = Fiber.current Fiber.yield end end; nil fibers.each(&:resume); nil fibers.each(&:resume); nil fibers = [] GC.start Running this code in IRB multiple times leads to consuming more and more memory every time. However every time I execute this code the amount of newly consumed memory is lower. I was able to repeat this bug with ruby 1.9.2.p290 and 1.9.3-head using 32 and 64 bit architecture. Here are some memory stats: a) 32bit Iter | VSZ | RSS 1 186268 63508 2 360196 119580 3 360340 147600 4 360484 178552 5 360616 199968 6 360612 210716 7 360612 221920 8 360612 224544 9 360612 229976 b) 64bit 1 395152 107600 2 739924 176532 3 739924 187972 4 739924 203300 5 739924 217716 6 739924 218344 7 739924 218540 8 739924 234040 9 739924 234256 We can see on our production instance that the more Fibers are in use the more memory is never reclaimed back to OS and the bigger the leak is. -- http://redmine.ruby-lang.org