I run Debian Etch on a 256MB Xen instance (provided by Mampi). For quite a long time I've been running into out of memory errors when using RubyGems. The usual transcript would go something like this:
$ sudo gem install rails
Bulk updating Gem source index for: http://gems.rubyforge.org
For a while, I hacked around this problem by increasing my RAM to 512MB when I needed to run RubyGems (which is a terrible solution, but I have the ability to increase my RAM at will, and when all you have is a hammer, everything looks like a nail). I was using the packaged version of RubyGems (0.90), which it turns out is horribly out of date now. I can't find a definitive source, but various mailing lists are pointing to an issue with the YAML parser causing Gems to use far too much memory.
The upgrade to a more recent version of RubyGems is fairly simple:
tar xzf rubygems-1.2.0.tgz
sudo ruby setup.rb
If you haven't removed your old (packaged) version of RubyGems, you will need to do so now, then create a symlink to the new Gems executable:
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
If you run the new version of Gems, you'll notice much reduced RAM usage.
Date: 10th September 2008.
Reading time: Less than 1 minute.