Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase Xmx and Xms for grails run-app

Tags:

grails

We currently are having performance issues with grails. It is taking about 10 seconds to load one of our main pages. I checked and saw that our grails app was starting up with 512 memory. We currently can use up to 3.5 gigs worth of ram.

I tried exporting the following:

export JAVA_OPTS="-XX:MaxPermSize=1024m -Xmx1024M -server"

After checking how it started up it seems as if it still started with the 512m setting. Where is this set?

like image 865
XanderLynn Avatar asked Aug 11 '09 14:08

XanderLynn


2 Answers

Csaba's answer is not accurate.

You don't need to tweak the startGrails script. This is something dangerous since the next time you will upgrade Grails, you will lose your configuration. I am not even talking about an environment that should be the same among multiple developers!

The solution is quite simple :

  1. Define GRAILS_OPTS="-XX:MaxPermSize=1024m -Xmx1024M -server"
  2. Do not define JAVA_OPTS
like image 128
fabien7474 Avatar answered Nov 13 '22 05:11

fabien7474


I assume you use Linux or some other unix variant.

Unfortunately it seems that (at least in Grails 1.1.1) the $GRAILS_HOME/bin/startGrails directly set a -Xmx512m value in JAVA_OPTS (on Windows, the startGrails.bat only set this if you do not provide your own value - I wonder why the unix script behaves different). It seems that the only way currently is to override this setting in startGrails.

Note that the above only true for development. If you deploy a war to an application server the memory settings in the server startup script will be used.

Update 2010.07.30: as fabian7474 wrote, from Grails 1.2.2 you can use GRAILS_OPTS to specify vm parameters and now it is the recommended way.

like image 24
Csaba_H Avatar answered Nov 13 '22 05:11

Csaba_H