Troubleshoot Grails / Groovy memory leak?

I have a Grails application that does a pretty decent amount of creating and destroying domain objects, and it seems to get out of the PermGen space very quickly. I performed the usual settings (intercepted PermGen to 256M, enabled the GC class, etc.), but not a cube.

I would not want to recommend some (and, hopefully, free or very inexpensive) tools for troubleshooting this kind of memory consumption in Groovy and / or Java? Or some methods you use to troubleshoot JVM memory?

Edit: this is when an application is deployed inside Tomcat in production mode; I have not tried with other containers. However, it would be nice to have some resources to track the problem.

+16
java jvm grails groovy
Apr 3 '09 at 0:50
source share
7 answers

You tried

-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled 

?

Together with the increase in the usual suspects ( -Xmx , -Xms , -XX:PermSize and -XX:MaxPermSize ) this resolved all the PermGen problems in our Tomcat production that occurred quite soon after the application was deployed. Never seen another OOM Exception after that. :-)

+10
Apr 22 '09 at 21:03
source share

I personally like VisualVM . There are definitely more powerful tools around, but it has a good convenience to power ratio.

+6
Apr 03 '09 at 8:18
source share

It may also be useful: http://burtbeckwith.com/blog/?p=73

+3
May 26 '11 at 17:48
source share

Eclipse Memory Analyzer is a free tool that is at least as good as yourkit.

+2
Apr 03 '09 at 8:14
source share

YourKit is a good tool that I have used several times to diagnose memory problems. It is commercial, but has a free trial version for one-time debugging.

+1
Apr 03 '09 at 1:21
source share

A problem that you face in the development or production process?

If you are in development, remember that Grails is constantly recompiling many aspects of your application (not only domain changes, but controller changes as well as other classes). I also have problems with PermGen, but most of them are caused by the constant recompilation of the files I'm working on. You can disable this feature.

http://www.grails.org/FAQ#Q:%20OMG%20I%20get%20OutOfMemoryErrors%20or%20PermGen%20Space%20errors%20when%20running%20Grails%20in%20development%20mode.%20What%20do%20I% 20do ?

If you are in production, then obviously you have a much more critical problem. PermGen memory problems relate to many of the structures Grails is built on, including Spring, Hibernate, and even Sun's own JVM. You can try setting the maximum heap size for your web container (Tomcat or Jetty).

You can also try another JVM implementation, such as Oracle JRockit, which should be significantly better when collecting garbage and other means of efficiency. I have never tried this myself, but since I am also in the middle of the developing and extensive Grails project, I can independently solve these problems. Good luck

+1
Apr 03 '09 at 1:24
source share

If this happens after you reinstall your application several times, you may be affected by this Grails error . The Tomcat FAQ also has several possible causes for PermGen leaks.

0
Apr 04 '09 at 11:46
source share



All Articles