From: Calamitas Date: 2010-11-01T23:58:29+09:00 Subject: Re: Ruby 1.9.1 linear memory increase in a simple for loop. On Mon, Nov 1, 2010 at 6:18 AM, Ritwik Banerjee wrote: > Thanks a lot for this detailed reply, Peter. I did, however, try the > same for-loop with explicit calls to the garbage collector. That slowed > down the increase in memory usage, but negligibly. I also restricted the > number of decimal places of each float to 6 (just to see whether the > number of bits taken up by each number can collectively matter so much), > but that didn't change anything. > > So, to sum it up, the memory usage can't be reduced by explicit calls to > the garbage collector at each iteration, and it can't be reduced by > restricting the number of bits used by each number. Curious, because I'm seeing the exact behavior I described. Using integers with or without triggering garbage collection gives a steady, linear increase in memory consumption, but nothing anywhere near what you are describing. I tried larger matrices and memory use increased faster but it is nowhere near what you are describing (unless you are using 10000x10000 matrices or so). When I use floats, memory use is constant. Can you try another version of Ruby? This is the version I'm using: peter@scruffy:~$ ruby1.9 -v ruby 1.9.0 (2008-10-04 revision 19669) [i486-linux] Peter