I am trying to run this code at a Ubuntu 13.10 64bits with 256mb:

array = []
str = "0"

20_000_000.times do |i|
  puts `free -m` if i % 1_000_000 == 0
  array << str.next!
end

But I get "Cannot allocate memory" when Ruby try to call "free -m".

As you can see, my server still has enough memory to run free:

             total       used       free     shared    buffers
cached
Mem:           238        172         66          0          5
40
-/+ buffers/cache:        126        112
Swap:            0          0          0
testing.rb:7:in ``': Cannot allocate memory - free (Errno::ENOMEM)
  from testing.rb:7:in `block in <main>'
  from testing.rb:6:in `times'
  from testing.rb:6:in `<main>'

Everything goes right if I remove backtick call.

It seems Ruby is invalidating memory before change process binary.

Ruby is CoW friendly when forking, isn't it?!

-- 
Posted via http://www.ruby-forum.com/.