On Sun, 16 Oct 2005, Eric Mahurin wrote:

> But it is not.  Have you tried this example?  On my 768MB machine, top shows
> it filling my physical memory and then the the CPU drops to about 3% because
> it starts swapping and my machine becomes very unresponsive.  I'd say that's
> a good indication that top is reporting the right thing.
>
> You could consider this case a bug in ruby or a bug in the simple test case
> above.  It doesn't matter where the fault lies, it still shows a memory
> leak.  The point is you better be careful with closures (block/lambda)
> because they carry all the variables in scope in Proc#binding in the current
> implementation.  Personally, I would like to see something done about this
> in ruby, but at minimum people need to be aware of this memory issue (as
> ruby stands now).

this is quite suspect:

[ahoward@localhost ~]$ for i in $(seq 0 18);do
   printf "$i => ";
   ruby -e' class << self; (2**ARGV.shift.to_i).times{|n| s = '42' * n; define_method("f#{ n }"){ 42 }}; end; GC::start; p IO::read("/proc/#{ $$ }/status").grep(/VmSize/) ' $i;
done

0 => ["VmSize:\t    2840 kB\n"]
1 => ["VmSize:\t    2840 kB\n"]
2 => ["VmSize:\t    2840 kB\n"]
3 => ["VmSize:\t    2840 kB\n"]
4 => ["VmSize:\t    2844 kB\n"]
5 => ["VmSize:\t    2840 kB\n"]
6 => ["VmSize:\t    2840 kB\n"]
7 => ["VmSize:\t    2844 kB\n"]
8 => ["VmSize:\t    2976 kB\n"]
9 => ["VmSize:\t    3456 kB\n"]
10 => ["VmSize:\t    3720 kB\n"]
11 => ["VmSize:\t    4380 kB\n"]
12 => ["VmSize:\t    6072 kB\n"]
13 => ["VmSize:\t    9456 kB\n"]
14 => ["VmSize:\t   15996 kB\n"]
15 => ["VmSize:\t   28704 kB\n"]
16 => ["VmSize:\t   53352 kB\n"]
17 => ["VmSize:\t  101220 kB\n"]
18 => ["VmSize:\t  194404 kB\n"]


note the progression is linear until 13 (note irony) and then climbs
exponentially - doubling each time.

-a
-- 
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| anything that contradicts experience and logic should be abandoned.
| -- h.h. the 14th dalai lama
===============================================================================