I have created an extensive Grails Web Application using lot of Plugins. I deployed this application on Tomcat Server (version-08), But as the records started growing, I get Java Heap Memory errors such as:
- OutOfMemoryError occurred when processing request
- JobExecutionException: java.lang.OutOfMemoryError: Java heap space
- java.lang.IllegalStateException: Already value for key bound to thread
- Error processing GroovyPageView: Error executing tag : Java heap space
I have tried lot of things available on web regarding increasing heap space allocated to my Tomcat Server, such as:
- Creating file 'setenv.bat' in tomcat/bin directory with content 'setx JAVA_OPTS="-server -Xmx1024m"'
- Setting System Environment Variable. Name:CATALINA_OPTS Value:-Xms256m -Xmx1024m
- setting these variables using 'set' and 'setx' command.
Added the following line as very first line in my BuildConfig.Groovy file:
grails.tomcat.jvmArgs= ["-Xms512m", "-Xmx1024m", "-XX:PermSize=512m", "-XX:MaxPermSize=1024m"]
I am Using Java-Melody to monitor the requests, memory, thread processes. I use this to check this:
P.S. In my Server Machine there are multiple Tomcat Server Installed on which different multiple applications are deployed. Secondly, I succeeded to increase my permGen Memory by writting: -XX:PermSize=512m -XX:MaxPermSize=1024m in Tomcat Java Configurations.
Any Help regarding this will be highly appreciated.
You can set memory limits with bin/tomcat7w.exe tool, in the Java tab.
However, I have not tried it with Tomcat 8 or with multiple Tomcat instances on the same server.
Hope this helps...