1

I'm running scripts inside GroovyConsole 2.4.5 on Windows 7 64-bit and they are crashing due to out of memory error. Runtime.getRuntime().maxMemory() shows 247MB and my PC has 32GB RAM. What is the way to increase memory available for GroovyConsole and underlying JVM?

I tried editing startGroovy.bat file with:

set GROOVY_OPTS="-Xmx2g -Xms1g"

and other values, but it had no effect.

Paul Jurczak
  • 7,008
  • 3
  • 47
  • 72

3 Answers3

2

I'm not on Windows, so can't test, but you should be able to use JAVA_OPTS instead of GROOVY_OPTS, ie:

set JAVA_OPTS="-Xmx1G"

Before you run groovyConsole

tim_yates
  • 167,322
  • 27
  • 342
  • 338
  • For me works for both, using `GROOVY_OPTS` or `JAVA_OPTS` since java execution in `startGroovy.bat` use both: `"%JAVA_EXE%" %GROOVY_OPTS% %JAVA_OPTS%...` however seems that OP has a specific problema with his configuration. – albciff Nov 02 '15 at 10:05
  • Setting environment variable `JAVA_OPTS` to `-Xmx1G` works. Unfortunately, larger values crash GroovyConsole on startup. I'm still puzzled why changes in `startGroovy.bat` file have no effect. – Paul Jurczak Nov 02 '15 at 10:19
1

You're already doing correctly, edit startGroovy.bat and simply try with g lowercase, to set GROOVY_OPTS:

set GROOVY_OPTS="-Xmx1g"

After some tries I see the follow effect, If I use " to set GROOVY_OPTS only work with one parameter, if I want to use two parameters -Xmx1g -Xms512m I've to remove " if not it doesn't works. So you can try with:

set GROOVY_OPTS=-Xmx1g -Xms512m

Instead of

set GROOVY_OPTS="-Xmx1g -Xms512m"

Hope it helps,

albciff
  • 18,112
  • 4
  • 64
  • 89
0

GROOVY_OPTS is an internal variable used by Groovy scripts (such as startGroovy.bat). Even if you set the value of this variable, it will be overwritten by the scripts. The scripts do not expect anything in GROOVY_OPTS.

Groovy scripts, however, expect that you pass Java options for Groovy in JAVA_OPTS.

Therefore, use the following (without quote characters; uppercase/lowercase G vs g does not matter):

set JAVA_OPTS=-Xmx2g -Xms1g
Maxim Masiutin
  • 3,991
  • 4
  • 55
  • 72