Grails PermGem 错误
我需要帮助解决这个问题。我需要有人向我解释为什么会发生这种情况以及如何预防或避免这种情况。
Exception in thread "Thread-747" java.lang.OutOfMemoryError: PermGen space
Exception in thread "Thread-748" java.lang.OutOfMemoryError: PermGen space
Exception in thread "Thread-759" java.lang.OutOfMemoryError: PermGen space
Exception in thread "Thread-760" java.lang.OutOfMemoryError: PermGen space
Exception in thread "Thread-764" java.lang.OutOfMemoryError: PermGen space
Exception in thread "Thread-765" java.lang.OutOfMemoryError: PermGen space
Exception in thread "Thread-766" java.lang.OutOfMemoryError: PermGen space
Exception in thread "Thread-767" java.lang.OutOfMemoryError: PermGen space
Exception in thread "Thread-773" java.lang.OutOfMemoryError: PermGen space
Exception in thread "Thread-774" java.lang.OutOfMemoryError: PermGen space
Exception in thread "Thread-780" java.lang.OutOfMemoryError: PermGen space
Exception in thread "Thread-781" java.lang.OutOfMemoryError: PermGen space
Exception in thread "Thread-788" java.lang.OutOfMemoryError: PermGen space
Exception in thread "Thread-789" java.lang.OutOfMemoryError: PermGen space
2011-06-20 14:42:10,668 [http-8080-6] ERROR [/CM].[grails] - Servlet.service() for servlet grails threw exception
java.lang.OutOfMemoryError: PermGen space
2011-06-20 14:42:10,668 [http-8080-6] ERROR [/CM].[default] - Servlet.service() for servlet default threw exception
java.lang.OutOfMemoryError: PermGen space
: java.lang.OutOfMemoryError: PermGen space
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116)
at _GrailsPackage_groovy$_run_closure8.doCall(_GrailsPackage_groovy:275)
at _GrailsPackage_groovy$_run_closure8.call(_GrailsPackage_groovy)
at _GrailsRun_groovy$_run_closure8.doCall(_GrailsRun_groovy:245)
at RunApp$_run_closure1.doCall(RunApp.groovy:35)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)
Caused by: java.lang.OutOfMemoryError: PermGen space
--- Nested Exception ---
java.lang.OutOfMemoryError: PermGen space
Error automatically restarting container: java.lang.OutOfMemoryError: PermGen space
Error executing script RunApp: PermGen space
java.lang.OutOfMemoryError: PermGen space
Error executing script RunApp: PermGen space
Application context shutting down...
Application context shutdown.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
PermGen 是 JVM 内存中用于加载类的区域。
当应用程序执行时,它会使用越来越多的内存,特别是当您处于调试环境中或者大量使用闭包时。
解决这个问题的方法就是添加更多!
这是通过在启动应用程序时向 JVM 传递一两个参数来完成的。
参数是:(
根据您的具体需要调整值)
PermSize 将是 PermGen 的初始大小,MaxPermSize 将是在像您的帖子中那样抛出异常之前它将增加的最大大小。
默认情况下,它设置为
64M
,如果您有一个“真正的”应用程序,这个值并不多。请注意:您的
总内存使用量
将为:堆大小 + Perm 大小
The PermGen is a region of your JVM's memory that is used to load classes.
As you application executes, it uses more and more of this memory, especially if you are in a debugging environment, of if you make extensive use of closures.
The way to fix this is to add more of it!
This is done by passing one or two parameters to the JVM when launching your application.
The parameters are :
(adjust the values to your specific needs)
The PermSize will be the initial size of the PermGen, and the MaxPermSize will be the maximum size at which it will increase before throwing you an exception like in your post.
By default, it is set to
64M
, which is not much if you have a 'real' application.PAY ATTENTION : Your
total memory usage
will be:Heap size + Perm Size
如果您使用的是 Servlet 3.0 版,那么即使增加内存也没有任何帮助,因为这是 groovy 编译器的问题。即将发布的新版本1.8.2/1.9(?)将解决这个问题。同时,您可以将 servlet 版本更改回“2.5”(在 BuildConfig.groovy 中),这将解决此问题。
将 servlet 版本更改为 2.5 的缺点是它无法部署到 Glassfish 应用程序服务器,因此丑陋的解决方法是更改为 2.5 并使用“run-app”。当您想要部署到 glassfish 时,请在 BuildConfig.groovy 中将 servlet 版本更改为“3.0”,运行“war”,然后将 war 部署到 Glassfish。
将其更改回“2.5”以再次在本地开发计算机上运行。
If you are using Servlet Version 3.0 then even increasing your memory won't be of any help since it's a problem with the groovy compiler. The new version 1.8.2/1.9 (?) which will be released soon will resolve this issue. In the meantime you can change the servlet version back to "2.5" (in BuildConfig.groovy) which will resolve this issue.
The drawback of changing the servlet version to 2.5 is that it cannot be deployed to Glassfish application server so the ugly workaround is change to 2.5 and use "run-app". When you want to deploy to glassfish change the servlet version to "3.0" in BuildConfig.groovy, run "war" and then deploy the war to Glassfish.
Change it back to "2.5" to run on local dev machine again.
检查常见问题解答
问:天哪,我在开发模式下运行 Grails 时遇到 OutOfMemoryErrors 或 PermGen Space 错误。我该怎么办?
最简单的方法是在发生这种情况时重新启动应用程序服务器。
Check the FAQ
Q: OMG I get OutOfMemoryErrors or PermGen Space errors when running Grails in development mode. What do I do?
Easiest just to restart your application server when it happens.
在STS IDE中设置如下:
-XX:MaxPermSize=512m -XX:PermSize=128m
我希望它有所帮助。
In the STS IDE set as per following:
-XX:MaxPermSize=512m -XX:PermSize=128m
I hope it helps.