Backport #461

Re: Hard question: Any ideas why this code leaks memory?

Added by nobu (Nobuyoshi Nakada) over 12 years ago. Updated over 1 year ago.




At Wed, 20 Aug 2008 04:46:24 +0900,
Sven C. Koehler wrote in [ruby-talk:311847]:

could someone help me understand why this code leaks memory? (I am using
ruby 1.8.6 (2007-12-03 patchlevel 113) [x86_64-linux].)

def rss_leaks
/VmRSS:\s+(\d+)/m.match("/proc/#{$$}/status") {|f| })[1].to_i

Calling GC.start inbetween does not help, but when we rewrote rss_leaks
this way the leaks disappeared:

def rss_no_leaks()
d ="/proc/#{$$}/status") {|f| }

Seems a bug.

Nobu Nakada


Updated by rogerdpack (Roger Pack) about 12 years ago

You should try SVN HEAD and see if it's still there.
See also


Updated by shyouhei (Shyouhei Urabe) almost 12 years ago

  • Assignee set to matz (Yukihiro Matsumoto)




Updated by shyouhei (Shyouhei Urabe) about 10 years ago

  • Status changed from Open to Assigned
  • ruby -v set to -




Updated by shyouhei (Shyouhei Urabe) about 10 years ago

  • Category set to core
  • Status changed from Assigned to Feedback

Can this still happen? I can't observe on my machine with
ruby 1.8.8dev (2010-09-24 revision 27061) [x86_64-linux].

irb(main):005:0> 100000.times { rss_leaks }; rss_leaks
=> 5616
irb(main):006:0> 100000.times { rss_leaks }; rss_leaks
=> 5616
irb(main):007:0> 100000.times { rss_leaks }; rss_leaks
=> 5616
irb(main):008:0> 100000.times { rss_leaks }; rss_leaks
=> 5616



Updated by jeremyevans0 (Jeremy Evans) over 1 year ago

  • ruby -v deleted (-)
  • Status changed from Feedback to Closed
  • Description updated (diff)
  • Project changed from Ruby 1.8 to Backport187
  • Tracker changed from Bug to Backport

Also available in: Atom PDF