From: Yukihiro Matsumoto Date: 2008-07-05T15:46:44+09:00 Subject: [ruby-core:17613] Re: [Ruby 1.8 - Bug #216] Memory leaks in 1.8.6p230 and p238 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(®s); rb_backref_set(Qnil); return result; } @@ -943,6 +944,7 @@ } re_copy_registers(RMATCH(match)->regs, ®s); + re_free_registers(®s); RMATCH(match)->str = rb_str_new4(str); rb_backref_set(match);