Tag Archives: jquery

Rhino: OptimizationLevel and Java Heap Space

When loading external JavaScript libraries like env.js or jquery.js
load('/Users/nl11087/dev/tradecard/modules/lib/env.rhino.1.2.js');
load('/Users/nl11087/dev/tradecard/modules/lib/jquery-1.8.3.js');

You might get a OutOfMemoryError:
exception from uncaught JavaScript throw: java.lang.OutOfMemoryError: Java heap space

Solution:
java org.mozilla.javascript.tools.shell.Main -opt -1
or
Packages.org.mozilla.javascript.Context.getCurrentContext().setOptimizationLevel(-1);