Increasing Tomcat’s memory

Posted by: Andrew Glover on 2009-08-18 09:38:00.0

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!


be the first to rate this blog


About Andrew Glover

Andrew is the founder of the easyb BDD framework and the co-author of Addison Wesley's "Continuous Integration", Manning's "Groovy in Action" and "Java Testing Patterns". He is an author for multiple online publications including IBM's developerWorks and Oreilly's ONJava and ONLamp portals. He actively blogs about software at thediscoblog.com.