java Grails/Groovy 内存泄漏故障排除?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/712187/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 13:28:41  来源:igfitidea点击:

Troubleshooting Grails/Groovy memory leaks?

javagrailsgroovyjvm

提问by Don Werve

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 rate. I've done the usual tweaks (bumped PermGen to 256M, enabled class GC, etc.), but no dice.

我有一个 Grails 应用程序,它执行了相当数量的域对象创建和销毁,而且它似乎以非常非常快的速度用完了 PermGen 空间。我已经做了通常的调整(将 PermGen 提高到 256M,启用类 GC 等),但没有骰子。

Would anyone care to recommend some (and hopefully free or very low-cost) tools for troubleshooting this sort of memory consumption in Groovy and/or Java? Or some techniques that you use to troubleshoot JVM memory problems?

有人愿意推荐一些(希望是免费或非常低成本的)工具来解决 Groovy 和/或 Java 中的此类内存消耗问题吗?或者你用来解决JVM内存问题的一些技术?

Edit: This is when the application is deployed inside Tomcat in production mode; I've not tried with other containers. Even so, it would be nice to have some resources for tracking down the problem.

编辑:这是在生产模式下将应用程序部署在 Tomcat 内部时;我没有尝试过其他容器。即便如此,最好有一些资源来追踪问题。

回答by Daniel Rinser

Have you tried

你有没有尝试过

-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled

?

?

Together with increasing the usual suspects (-Xmx, -Xms, -XX:PermSizeand -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. :-)

再加上增加常见的疑点(-Xmx-Xms-XX:PermSize-XX:MaxPermSize),这解决了我们生产 Tomcat 上的所有 PermGen 问题,这些问题在部署应用程序后很快就发生了。在那之后再也没有见过另一个 OOM 异常。:-)

回答by Joachim Sauer

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

我个人喜欢VisualVM。周围肯定有更强大的工具,但这个工具具有很好的可用性与功率比。

回答by Mulone

This could useful as well: http://burtbeckwith.com/blog/?p=73

这也很有用:http: //burtbeckwith.com/blog/?p=73

回答by kohlerm

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

Eclipse Memory Analyzer是一款免费工具,至少与 Yourkit 一样好。

回答by andri

YourKitis 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.

YourKit是一个很好的工具,我曾多次使用它来诊断内存问题。它是商业的,但它有一个免费的评估版,可用于一次性调试。

回答by andri

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

如果您正在开发中,请记住 Grails 会不断地重新编译应用程序的许多方面(不仅是域更改,还有控制器更改和其他类)。我也有 PermGen 问题,但大多数是由我正在处理的文件的稳定重新编译触发的。您可以关闭此功能

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

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

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).

如果你在生产中,那么显然你有一个更严重的问题。PermGen 内存问题归因于许多构建 Grails 的框架,包括 Spring、Hibernate,甚至 Sun 自己的 JVM。您可以尝试调整 Web 容器(Tomcat 或 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!

您还可以尝试不同的 JVM 实现,例如 Oracle 的 JRockit,它应该在垃圾收集和其他效率方法方面要好得多。我自己从未尝试过,但由于我也在开发和扩展 Grails 项目,因此我可能会自己购买这些问题的解决方案。祝你好运!

回答by Ben Williams

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

如果在您多次热重新部署应用程序后发生这种情况,您可能会受到此 Grails 错误的影响。在Tomcat的常见问题也有PermGen的泄漏的几个可能的原因。