I guess you'll have to convince your self 
yes I have because it just did not happen,
526/28 > uname -a && ruby -v
Linux zenwalk 2.6.18.1 #1 SMP PREEMPT Mon Oct 30 15:32:27 CET 2006
i686 athlon-4 i386 GNU/Linux
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]
the program was
N = 1000
M = 1000
a =
loop do
N.times do
a << Array.new( M ){ Object.new }
end
N.times do
a.shift
end
end
Ruby allocated up to 43M and then decided to release 3M regularly,
seems a very reasonable strategy to me.
I feel that it would be nice to show the exact leaking code so that I
can run it.
You need to be careful what it is you are testing.
Try the tiny variation I've supplied below as it is, it'll execute relatively benignly. Then comment out the crucial line indicated by the comment. If you dare. BTW, if you run this make sure you keep on top of things and kill it before it starts screwing up your machine. Make sure you don't have anything important unsaved.
Why don't we keep all the 'a' arrays we generate? Shouldn't cause a problem right? If fact if you don't comment out the crucial line memory use will grow relatively slowly. If you do comment it out, then, well, it *is* your machine.
BTW, the *only* thing special about nil is that there is only one of them. You could use a symbol, true/false, a number -- just don't create a new object.
What happens if you comment out the whole second N.times loop? I get strangely similar behaviour to just commenting out the crucial line. Why's that? Because, in neither case, none of the arrays of Object is being collected.
If you get the behaviour I'm getting, how do you explain it other than as a leak?
Innocent bystanders: if you comment out that crucial line before running the program PAY ATTENTION AND BE READY TO KILL THE PROCESS BEFORE IT LOCKS UP YOUR MACHINE (very bad on OS X, it is an abrupt lockup of the system after about 20s on my machine, Ctrl-C won't work, get either your activity monitor up and visible or the force quit dialog).
N = 1000
M = 1000
as =
loop do
a =
N.times do
a << Array.new( M ){ Object.new }
end
N.times do
a[0] = nil # <<< the crucial line
a.shift
end
as << a
GC.start
STDERR << '.'
end
Cheers,
Bob
···
On 25-Oct-07, at 1:57 PM, Robert Dober wrote:
On 10/25/07, Bob Hutchison <hutch@recursive.ca> wrote:
Cheers
Robert
--
what do I think about Ruby?
http://ruby-smalltalk.blogspot.com/
----
Bob Hutchison -- tumblelog at http://www.recursive.ca/so/
Recursive Design Inc. -- weblog at http://www.recursive.ca/hutch
http://www.recursive.ca/ -- works on http://www.raconteur.info/cms-for-static-content/home/