I've been continuing to work with the Grails framework and found an interesting issue. When working with the Tomcat application server I run into several issues related to out of memory errors with Grails applications.
Attempts to resolve this with -Xmx512m or some other setting for the memory heap size failed to work. This seems to be due to the large number of elements (controllers, domains, etc) in my grails app that load classes. I believe this is related to issues of lots of use of reflection (not sure). It does appear that this memory is alive during the entire life of the application (not garbage collected). After installing several plug-ins and increasing the size of the application quite a bit this occurred. It also seems to be partly related to the creation of an additional "Context Path" for an application in Tomcat.
I found some reference to Tomcat 6 having better "perm size" management on the net vs Tomcat 5 series. Though nothing of a definitive nature. I saw it seems related since it removing the extra "Context Path" for this grails application seemed to resolve things. Perhaps it is an issue with grails applications in multiple Context Path's but the perm gen size increase did resolve it cleanly.
My current options line for catalina.sh:
JAVA_OPTS='-Xmx512m -XX:MaxPermSize=256m -server -Djava.awt.headless=true'
2 comments:
Thanks for this Doug, I was having real issues with the memory heap size!
Just an FYI...
This is a common problem with any web application that uses technologies that dynamically generate classes (which are, of course, added to the permgen space). So using frameworks like hibernate, iBatis, and Spring can very easily get you into this mess. My point being that this isn't a grails problem, it's a dynamic class generation problem.
Post a Comment