From: "Sven C. Koehler" Date: 2008-08-20T20:19:43+09:00 Subject: Re: [Bug:1.8] Re: Hard question: Any ideas why this code leaks memory? On Wed, Aug 20, 2008 at 03:44:15PM +0900, Nobuyoshi Nakada wrote: > At Wed, 20 Aug 2008 12:49:41 +0900, > Sven C. Koehler wrote in [ruby-talk:311908]: > > Yep, and it seems to be fixed in 1.8.7-p71 : > > http://rubyforge.org/tracker/?func=detail&aid=15425&group_id=426&atid=1698 > > Hmmm, indeed. But it seems to occur with the latest 1.8. I tried some of the patches mentioned on the page on my ruby-1.8.6, and this is the patch which worked for me (saves me some time before upgrading to 1.8.7). -S. --- parse.old.y 2008-08-20 10:59:56.000000000 +0000 +++ parse.y 2008-08-20 11:08:16.000000000 +0000 @@ -5716,7 +5716,7 @@ rb_mem_clear(vars+i, len-i); } else { - *vars++ = (VALUE)ruby_scope; + *vars++ = 0; rb_mem_clear(vars, len); } ruby_scope->local_vars = vars; @@ -5732,6 +5732,7 @@ if (!(ruby_scope->flags & SCOPE_CLONE)) xfree(ruby_scope->local_tbl); } + ruby_scope->local_vars[-1] = 0; /* no reference needed */ ruby_scope->local_tbl = local_tbl(); } }