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 <redmine / ruby-lang.org> 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);