[ruby_1_8] memory leak by Array#flatten?

e$B1J0f!wCNG=!%6e9)Bg$G$9!%e(B

Array#flatten e$B$Ke(B memory leak
e$B$,$"$k$N$G$O$J$$$+$H$$$&5$$,$7$^$9!%e(B

e$B<!$N%9%/%j%W%H$r<B9T$9$k$H!$e(B


coords = []
n = 0
(-10…300).step(5){|n| coords << [n, 100] }

max_cnt = 0
max_len = 0
pre_cnt = 0
pre_len = 0
loop{
coords.flatten

cnt = 0
len = 0
ObjectSpace.each_object(Array){|obj|
cnt += 1
len += obj.length
}
p [[cnt, max_cnt], [len, max_len]] if pre_cnt > cnt || pre_len > len

GC ?

max_cnt = cnt if max_cnt < cnt
max_len = len if max_len < len
pre_cnt, pre_len = cnt, len
}

e$BC<Kv$K=PNO$5$l$k%m%0$r8+$F$$$k8B$j$Oe(B
Array e$B%%V%8%’%/%H$NAm?t$$h$S$=$N%5%$%:$NAm7W$Oe(B
GC e$B$,F/$$$FF,BG$A$K$J$C$F$$$k$h$&$J$N$G$9$,!$e(B
e$B%W%m%;%9$N%a%b%j>CHqNL$O$I$s$I$sA}Bg$7$F$$$-$^$9!%e(B

e$B<B9T$7$?%P%$%J%j$Oe(B

$ ruby -v
ruby 1.8.7 (2008-05-21 patchlevel 5000) [i686-linux]

e$B$G$9e(B (ruby_1_8 revision 16505)e$B!%e(B

e$B1J0f!wCNG=!%6e9)Bg$G$9!%e(B

From: Hidetoshi NAGAI [email protected]
Subject: [ruby-dev:34789] [ruby_1_8] memory leak by Array#flatten ???
Date: Wed, 21 May 2008 17:59:32 +0900
Message-ID: [email protected]

Array#flatten e$B$Ke(B memory leak e$B$,$"$k$N$G$O$J$$$+$H$$$&5$$,$7$^$9!%e(B

e$B$3$l$G$$$$$N$G$7$g$&$+!)e(B

Index: array.c

— array.c (revision 16505)
+++ array.c (working copy)
@@ -3143,6 +3143,8 @@
ary = rb_ary_pop(stack);
}

  • st_free_table(memo);
  • return result;
    }

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:34792] Re: [ruby_1_8] memory leak by
Array#flatten ???”
on Wed, 21 May 2008 21:20:47 +0900, Hidetoshi NAGAI
[email protected] writes:
|
|e$B1J0f!wCNG=!%6e9)Bg$G$9!%e(B
|
|From: Hidetoshi NAGAI [email protected]
|Subject: [ruby-dev:34789] [ruby_1_8] memory leak by Array#flatten ???
|Date: Wed, 21 May 2008 17:59:32 +0900
|Message-ID: [email protected]
|> Array#flatten e$B$Ke(B memory leak e$B$,$"$k$N$G$O$J$$$+$H$$$&5$$,$7$^$9!%e(B
|
|e$B$3$l$G$$$$$N$G$7$g$&$+!)e(B

e$B3N$+$K$=$NDL$j$G$9$M!#%3%_%C%H$7$F$*$-$^$9!#e(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs