Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

JavaWorld Daily Brew

Increasing Tomcat’s memory

 

If you happen to casually peruse the Grails documentation, you might notice the following note regarding memory (please note, man, that the emphasis has been added by yours truly):

If memory is not a problem on your server then allocate a large amount of memory, such as 512M or more. Also use the server VM option. EG: (-server -Xms512M -Xmx512M). Usually it is better to set both min and max heap size to the same in server applications.

Accordingly, if you’re using Tomcat (and you’d like to allocate a lot of memory), you can edit the catalina.(bin | sh) file found in the bin directory of your Tomcat installation.

For example, on a Windows machine (where I currently find myself these days), I added the following statement around line 71:

set JAVA_OPTS=%JAVA_OPTS% -server -Xms512M -Xmx512M

Incidentally, non-scientific testing of perceived performance before and after the changes listed above resulted in an extremely noticeable speed up in processing of a high volume of RESTful requests. It seems like the above note from Grails is good advice; plus, adding the -server option is a good idea in general due to the HotSpot VM’s ability to selectively compile heavily used code.

You can now follow The Disco Blog on Twitter, baby!