Q:

How do I specify heap size configuration in a config file

gem install fails with the following error, How do I specify the heap size configuration in a common place so that I don't have to re-define this every time. 
Error: Your application used more memory than the safety cap of 500m.
Specify -J-Xmx####m to increase it (#### = cap size in MB). 
Specify -w for full OutOfMemoryError stack trace. 

A:

This error and message are actually coming from jruby, not gem.   Fortunately, jruby checks for default options in the JRUBY_OPTS environment variable.   
So, try export JRUBY_OPTS=-J-Xmx1024m, and then, whenever you call gem install, jruby should automatically run with a 1024MB memory cap.