Project

General

Profile

Actions

Bug #216

closed

Memory leaks in 1.8.6p230 and p238

Added by igal (Igal Koshevoy) over 15 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
[ruby-core:17518]

Description

=begin
WARNING: Do not use Ruby 1.8.6 releases p230 through p238 in production! There are bugs in the Ruby interpreter that cause it leak memory. Please use a Ruby release that's based on a patched version of the p111 or p114 code until this is resolved.

I've put together code which demonstrates this at: http://pastie.org/226715

-igal
=end

Actions #1

Updated by rabarca (Rolando Abarca) over 15 years ago

=begin
do you have a more specific test?
=end

Actions #2

Updated by igal (Igal Koshevoy) over 15 years ago

=begin
Rolando Abarca: No, my test merely proves that a memory leak exists, but doesn't identify where. If you or someone else has time to try to build a more specific test, it'd be much appreciated because it'll be much easier for the developers to identify the actual cause of the memory leak and address it.
=end

Actions #3

Updated by Anonymous over 15 years ago

=begin
For what it's worth:

I seem to be experiencing the memory leak in p256 as well:

ruby 1.8.6 (2008-06-30 patchlevel 256) [i686-linux]

I don't know much about it yet, but I'm seeing the leak in two
completely different long-running processes, neither of which
is based on anything Rails-related. (One is a server running
nitro/og/webrick, the other is a home-grown game admin system.)

Regards,

Bill

=end

Actions #4

Updated by Anonymous over 15 years ago

=begin
I can also confirm memory leaks running a bunch of different ruby code including rails, merb and various daemons.

-Ezra
=end

Actions #5

Updated by rabarca (Rolando Abarca) over 15 years ago

=begin
Here are some other tests, and here are my results. VmSize is displayed before and after running the main loop (check the test files).
Test files are here: http://pastie.org/227949
test04.rb is the only one not leaking.

rolando@dev02:~/sandbox/ruby_memory_test$ ruby run_tests.rb
test01.rb
ruby 1.8.6 (2007-09-24 patchlevel 111) [i686-linux]
VmSize: 3108 kB
VmSize: 3240 kB
ruby 1.8.6 (2008-07-03 patchlevel 265) [i686-linux]
VmSize: 3116 kB
VmSize: 96968 kB

test02.rb
ruby 1.8.6 (2007-09-24 patchlevel 111) [i686-linux]
VmSize: 2972 kB
VmSize: 3104 kB
ruby 1.8.6 (2008-07-03 patchlevel 265) [i686-linux]
VmSize: 2984 kB
VmSize: 115580 kB

test03.rb
ruby 1.8.6 (2007-09-24 patchlevel 111) [i686-linux]
VmSize: 2972 kB
VmSize: 3104 kB
ruby 1.8.6 (2008-07-03 patchlevel 265) [i686-linux]
VmSize: 2984 kB
VmSize: 115580 kB

test04.rb
ruby 1.8.6 (2007-09-24 patchlevel 111) [i686-linux]
VmSize: 2976 kB
VmSize: 2976 kB
ruby 1.8.6 (2008-07-03 patchlevel 265) [i686-linux]
VmSize: 2984 kB
VmSize: 2984 kB

regards,
rolando./
=end

Actions #6

Updated by igal (Igal Koshevoy) over 15 years ago

=begin
Rolando Abarca,

Excellent work, your sample code clearly demonstrates the memory leak and narrows its location. I can confirm that p238 and p265 leak memory on the first three tests, while p111ubuntu is fine.

I've played with this further and provided a broader series of Regexp related methods that are affected: http://pastie.org/228006

-igal
=end

Actions #7

Updated by matz (Yukihiro Matsumoto) over 15 years ago

=begin
Hi,

In message "Re: [ruby-core:17608] [Ruby 1.8 - Bug #216] Memory leaks in 1.8.6p230 and p238"
on Sat, 5 Jul 2008 08:53:17 +0900, Igal Koshevoy writes:

|Excellent work, your sample code clearly demonstrates the memory leak and narrows its location. I can confirm that p238 and p265 leak memory on the first three tests, while p111ubuntu is fine.

The following patch from ruby_1_8 should fix the leak. Could you try?

						matz.

Index: re.c

--- re.c (revision 16437)
+++ re.c (revision 16438)
@@ -927,6 +927,7 @@
}

  if (result < 0) {
  • re_free_registers(&regs);
    rb_backref_set(Qnil);
    return result;
    }
    @@ -943,6 +944,7 @@
    }

    re_copy_registers(RMATCH(match)->regs, &regs);

  • re_free_registers(&regs);
    RMATCH(match)->str = rb_str_new4(str);
    rb_backref_set(match);

=end

Actions #8

Updated by igal (Igal Koshevoy) over 15 years ago

=begin
Good news, I think the memory leak problem is fixed.

I've applied Matz's re.c patch to my copy of p265 (head of ruby_1_8_6) and ran it against (1) my earlier test which used a complete Rails stack, (2) Rolando Abarca's contributed tests, and (3) my later tests for String/Regexp. Memory usage for all these is now stable.

Matz, thank you so much for resolving this. And thank you Rolando for contributing the specific test case that helped isolate the leak.

-igal
=end

Actions #9

Updated by rabarca (Rolando Abarca) over 15 years ago

=begin
Hi,

On Jul 5, 2008, at 2:46 AM, Yukihiro Matsumoto wrote:

The following patch from ruby_1_8 should fix the leak. Could you try?

 					matz.

yes, it works fine :-)
Here are the results from my tests:

test01.rb
ruby 1.8.6 (2007-09-24 patchlevel 111) [i686-linux]
VmSize: 3108 kB
VmSize: 3240 kB
ruby 1.8.6 (2008-07-03 patchlevel 265) [i686-linux]
VmSize: 3116 kB
VmSize: 3248 kB

test02.rb
ruby 1.8.6 (2007-09-24 patchlevel 111) [i686-linux]
VmSize: 2972 kB
VmSize: 3104 kB
ruby 1.8.6 (2008-07-03 patchlevel 265) [i686-linux]
VmSize: 2988 kB
VmSize: 3120 kB

test03.rb
ruby 1.8.6 (2007-09-24 patchlevel 111) [i686-linux]
VmSize: 2972 kB
VmSize: 3104 kB
ruby 1.8.6 (2008-07-03 patchlevel 265) [i686-linux]
VmSize: 2984 kB
VmSize: 3116 kB

test04.rb
ruby 1.8.6 (2007-09-24 patchlevel 111) [i686-linux]
VmSize: 2976 kB
VmSize: 2976 kB
ruby 1.8.6 (2008-07-03 patchlevel 265) [i686-linux]
VmSize: 2988 kB
VmSize: 2988 kB

meaning HEAD from ruby_1_8_6 does not leak after applying your patch.
thanks!

Rolando Abarca M.

=end

Actions #10

Updated by matz (Yukihiro Matsumoto) over 15 years ago

  • Status changed from Open to Closed

=begin

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0