jruby rails : Java::JavaLang::OutOfMemoryError: Java heap space

jruby rails : Java::JavaLang::OutOfMemoryError: Java heap space

我正在尝试编译我的 javascript 资产。我已经包含了 plotly.js 大小将近 2MB 的文件。我还包含了 angualr2.dev.js 大小为 1MB 的文件。

每当我使用命令 rake assets:precompile RAILS_ENV=production 编译我的资产时,我都会遇到以下错误。

Java::JavaLang::OutOfMemoryError: Java heap space
org.mozilla.javascript.NativeArray.<init>(org/mozilla/javascript/NativeArray.jav
a:66)
org.mozilla.javascript.Context.newArray(org/mozilla/javascript/Context.java:1626
)
org.mozilla.javascript.ScriptRuntime.newArrayLiteral(org/mozilla/javascript/Scri
ptRuntime.java:3733)
org.mozilla.javascript.Interpreter.interpretLoop(org/mozilla/javascript/Interpre
ter.java:1776)
org.mozilla.javascript.Interpreter.interpret(org/mozilla/javascript/Interpreter.
java:815)
org.mozilla.javascript.InterpretedFunction.call(org/mozilla/javascript/Interpret
edFunction.java:109)
org.mozilla.javascript.NativeArray.iterativeMethod(org/mozilla/javascript/Native
Array.java:1635)
org.mozilla.javascript.NativeArray.execIdCall(org/mozilla/javascript/NativeArray
.java:330)
org.mozilla.javascript.IdFunctionObject.call(org/mozilla/javascript/IdFunctionOb
ject.java:97)
org.mozilla.javascript.Interpreter.interpretLoop(org/mozilla/javascript/Interpre
ter.java:1479)
org.mozilla.javascript.Interpreter.interpret(org/mozilla/javascript/Interpreter.
java:815)
org.mozilla.javascript.InterpretedFunction.call(org/mozilla/javascript/Interpret
edFunction.java:109)
org.mozilla.javascript.NativeArray.iterativeMethod(org/mozilla/javascript/Native
Array.java:1635)
org.mozilla.javascript.NativeArray.execIdCall(org/mozilla/javascript/NativeArray
.java:330)
org.mozilla.javascript.IdFunctionObject.call(org/mozilla/javascript/IdFunctionOb
ject.java:97)
org.mozilla.javascript.Interpreter.interpretLoop(org/mozilla/javascript/Interpre
ter.java:1479)
org.mozilla.javascript.Interpreter.interpret(org/mozilla/javascript/Interpreter.
java:815)
org.mozilla.javascript.InterpretedFunction.call(org/mozilla/javascript/Interpret
edFunction.java:109)
org.mozilla.javascript.NativeArray.iterativeMethod(org/mozilla/javascript/Native
Array.java:1635)
org.mozilla.javascript.NativeArray.execIdCall(org/mozilla/javascript/NativeArray
.java:330)
org.mozilla.javascript.IdFunctionObject.call(org/mozilla/javascript/IdFunctionOb
ject.java:97)
org.mozilla.javascript.Interpreter.interpretLoop(org/mozilla/javascript/Interpre
ter.java:1479)
org.mozilla.javascript.Interpreter.interpret(org/mozilla/javascript/Interpreter.
java:815)
org.mozilla.javascript.InterpretedFunction.call(org/mozilla/javascript/Interpret
edFunction.java:109)
org.mozilla.javascript.NativeArray.iterativeMethod(org/mozilla/javascript/Native
Array.java:1635)
org.mozilla.javascript.NativeArray.execIdCall(org/mozilla/javascript/NativeArray
.java:330)
org.mozilla.javascript.IdFunctionObject.call(org/mozilla/javascript/IdFunctionOb
ject.java:97)
org.mozilla.javascript.Interpreter.interpretLoop(org/mozilla/javascript/Interpre
ter.java:1479)
org.mozilla.javascript.Interpreter.interpret(org/mozilla/javascript/Interpreter.
java:815)
org.mozilla.javascript.InterpretedFunction.call(org/mozilla/javascript/Interpret
edFunction.java:109)
org.mozilla.javascript.NativeArray.iterativeMethod(org/mozilla/javascript/Native
Array.java:1635)
org.mozilla.javascript.NativeArray.execIdCall(org/mozilla/javascript/NativeArray
.java:330)
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

我该如何解决这个问题??

尝试使用备用 ExecJS 运行时进行预编译(例如安装 node

... 而不是 gem 'therubyrhino'