Hi Sal,
You need to increase the memory assigned to the javascript node of the serverconf.xml file .
The maxMB parameter needs to be updated
Refer :
<!-- Configuring the JavaScript interpreter
maxMB : Maximum size in megabytes before running the garbage collector Default: 64
stackSizeKB : Size of each stack chunk in kilo octets Default: 8 -->
<javaScript maxMB="64" stackSizeKB="8"/>
Regards,
Adhiyan