How do I specify heap size configuration in a conf

2019-03-31 18:52发布

问题:

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.

回答1:

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.