From: Eric Mahurin Date: 2007-10-26T01:40:56+09:00 Subject: Re: pop/push, shift/unshift On 10/25/07, Bob Hutchison wrote: > Hi, > > On 25-Oct-07, at 1:12 AM, Robert Dober wrote: > > > Well I guess I have to believe you, but I would *love* to reproduce it > > if I do > > times do > > << > > end > > times do > > shift > > end > > it will leak? > > How else would you describe the 10k Things left in memory after the > shifts in the modified version of your test case? The problem is that Ruby's COW (copy-on-write) scheme is messed up for arrays. I've found much worse cases performance and memory-wise. Try doing a small #slice on a big array a bunch and modify the small slices. I made a 1.9 patch a couple years ago that fixed the problem and made ALL operations near the front just as fast as the operations on the back. Unfortunately, it never made it in. The way I did it might be unique, not sure. I thought C++ deque does something similiar, but it doesn't. When I find time, I'll try to do the fix again.