[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

leak stuff

Roger Pack

4/29/2008 7:13:00 PM

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-....

6 Answers

Roger Pack

4/29/2008 7:23:00 PM

0


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

> 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&gr...
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.


Joel VanderWerf

4/29/2008 8:17:00 PM

0

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

MenTaLguY

4/29/2008 10:32:00 PM

0

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.

-mental


Joel VanderWerf

4/29/2008 11:35:00 PM

0

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

Roger Pack

4/30/2008 2:28:00 AM

0

> 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://pennys...

Roger Pack

4/30/2008 8:15:00 PM

0

> 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-....