Troubleshooting Grails/Groovy memory leaks?

后端 未结 7 1271
难免孤独
难免孤独 2020-12-08 01:41

I\'ve got a Grails application that does a fairly decent amount of domain object creation and destruction, and it seems to run out of PermGen space at a very, very rapid rat

相关标签:
7条回答
  • 2020-12-08 01:48

    I personally like VisualVM. There are definitely more powerful tools around, but this one has got a nice usability-to-power ratio.

    0 讨论(0)
  • 2020-12-08 01:54

    Have you tried

    -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled
    

    ?

    Together with increasing the usual suspects (-Xmx, -Xms, -XX:PermSize and -XX:MaxPermSize) this resolved all the PermGen issues on our production Tomcat, which had occured pretty soon after deploying the app. Never seen another OOM-Exception after that. :-)

    0 讨论(0)
  • YourKit is a nice tool I have used multiple times to diagnose memory issues. It is commercial, but it has a free evaluation version available for one-shot debugging.

    0 讨论(0)
  • 2020-12-08 01:56

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

    0 讨论(0)
  • 2020-12-08 01:57

    Is the problem you're having occurring in development or production?

    If you're in development, remember that Grails is constantly recompiling many aspects of your application (not only Domain changes, but controller changes, and other classes as well). I have PermGen issues too, but most are triggered by the steady recompilation of the files I'm working on. You can turn this feature off

    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're in production, then obviously you have a much more critical problem. PermGen memory issues are attributed to many of the frameworks on which Grails is built, including Spring, Hibernate, and even Sun's own JVM. You could try tweaking the maximum heap size for your Web container (Tomcat or Jetty).

    You could also try a different implementation of the JVM, like Oracle's JRockit, which is supposed to be considerably better at garbage collection and other means of efficiency. I've never tried it myself, but since I too am in the middle of developing and extensive Grails project, I may be shopping solutions to these problems myself. Good luck!

    0 讨论(0)
  • 2020-12-08 02:07

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

    0 讨论(0)
提交回复
热议问题