The following script uses more memory as N gets bigger. Should I
expect it to run in constant space? If not, what do I need to know to
understand how the GC reclaims memory? I'd like to know, so I can get
an idea of the memory usage of a long-running process, like a server
written in Ruby.
Cheers,
Doug
----------------------------------------
#!/usr/local/bin/ruby
N = Integer(ARGV.shift || 1)
def test()
li1 = (1..10000).to_a
li2 = li1.slice(0, li1.length)
while (not li2.empty?)
li1.push(li2.shift)
end
end
for i in 0 .. N
test()
end