Leak stuff

Has anything being done on these?

def leak
  "name".split(/::/)
end

loop {leak} # leaks

loop do
rand(10000000).to_s.to_sym # leaks
end

?
-R

···

--
Posted via http://www.ruby-forum.com/.

Has anything being done on these?

def leak
"name".split(/::/)
end

loop {leak} # leaks

To answer my own question.
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=15425&group_id=426
It appears to still be a leak in Ruby, though fixed. It occurs whenever you have a regexp replace [?] within a function with no variables, or something like that.

loop do
rand(10000000).to_s.to_sym # leaks
end

This one is also still in Ruby, I believe.

···

On Apr 29, 2008, at 1:12 PM, Roger Pack wrote:

def leak

> "name".split(/::/)
> end
>
> loop {leak} # leaks

This leaks too. Not sure if it's related or not.

def grow
  for i in 1..100
    eval "b#{i}=1"
  end
end
15000.times {grow}

from http://pennysmalls.com/

Roger Pack wrote:

loop do
rand(10000000).to_s.to_sym # leaks
end

This one is also still in Ruby, I believe.

Not a leak. Symbols are not collectable.

···

--
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

This leaks too. Not sure if it's related or not.

def grow
  for i in 1..100
    eval "b#{i}=1"
  end
end
15000000.times {grow}

Appears that it was the same bug.
Attached is a patch which works at least on linux, but not on mac os
[for some
reason--maybe mine dynamically links to an old copy or something].
-R

Index: parse.y

···

===================================================================
--- parse.y (revision 16244)
+++ parse.y (working copy)
@@ -5821,7 +5821,8 @@
                if (!(ruby_scope->flags & SCOPE_CLONE))
                    xfree(ruby_scope->local_tbl);
            }
- ruby_scope->local_tbl = local_tbl();
+ ruby_scope->local_vars[-1] = 0;
+ ruby_scope->local_tbl = local_tbl();
        }
     }
     local_pop();

--
Posted via http://www.ruby-forum.com/\.

It depends on the Ruby implementation.

-mental

···

On Wed, 30 Apr 2008 05:16:34 +0900, Joel VanderWerf <vjoel@path.berkeley.edu> wrote:

Roger Pack wrote:

loop do
rand(10000000).to_s.to_sym # leaks
end

This one is also still in Ruby, I believe.

Not a leak. Symbols are not collectable.

MenTaLguY wrote:

···

On Wed, 30 Apr 2008 05:16:34 +0900, Joel VanderWerf <vjoel@path.berkeley.edu> wrote:

Roger Pack wrote:

loop do
rand(10000000).to_s.to_sym # leaks
end

This one is also still in Ruby, I believe.

Not a leak. Symbols are not collectable.

It depends on the Ruby implementation.

Is that changing in MRI?

--
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407