From: Robert Klemme Date: 2010-03-06T23:50:04+09:00 Subject: Re: Cannot allocate memory (Errno::ENOMEM) On 03/05/2010 11:43 PM, Tom Shealy wrote: > I'm using a ruby to setup an ec2 instance as part of a bootscript. The > ruby script runs out of memory and exits with an error. I believe this > may be related to the fact that the ruby script makes a lot of system > calls (using the backtick `). I don't need to hang on the the output of > the system call after checking it, Note, your Ruby script may run out of memory while *running* the command already if that command yields too much output. > and I'm wondering if I should be > doing something to release resources after the forked process finishes. > Any advice is greatly appreciated. Since we don't see the code this is difficult to do. If your sub processes yield so much output you should probably consider not using backticks. If you need to look at the output you could use IO#popen or have the process write to a file. If you do not need the output, you can redirect to null device or use system and let the program write to the terminal. It all depends. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/