Grails PermGem 错误

发布于 2024-11-16 01:32:58 字数 2894 浏览 1 评论 0 原文

我需要帮助解决这个问题。我需要有人向我解释为什么会发生这种情况以及如何预防或避免这种情况。

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.

I need help with this problem. I need someone to explain to me why is this happening and how to prevent or avoid it.

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

橘味果▽酱 2024-11-23 01:32:58

PermGen 是 JVM 内存中用于加载类的区域。

当应用程序执行时,它会使用越来越多的内存,特别是当您处于调试环境中或者大量使用闭包时。

解决这个问题的方法就是添加更多!

这是通过在启动应用程序时向 JVM 传递一两个参数来完成的。

参数是:(

-XX:MaxPermSize=256m
-XX:PermSize=128m

根据您的具体需要调整值)

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 :

-XX:MaxPermSize=256m
-XX:PermSize=128m

(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

傲性难收 2024-11-23 01:32:58

如果您使用的是 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.

烟织青萝梦 2024-11-23 01:32:58

检查常见问题解答

问:天哪,我在开发模式下运行 Grails 时遇到 OutOfMemoryErrors 或 PermGen Space 错误。我该怎么办?

从 Grails 0.6 开始,Grails 会自动重新编译 Java 源代码并
域类使用预编译,然后服务器重新启动。这
如果服务器长时间运行,可能会导致永久代空间耗尽
时间和许多变化发生了。如果是,您可以禁用此功能
对您来说并不重要:

grails -Ddisable.auto.recompile=true run-app

Windows 上的 Grails 0.6 也存在一个问题,您会得到
由于开发模式活动期间出现 OutOfMemoryErrors
到重新编译。这可能可以在 SVN head 中解决,但是如果你看到
对于这个问题,上述选项也可以提供帮助。

最简单的方法是在发生这种情况时重新启动应用程序服务器。

Check the FAQ

Q: OMG I get OutOfMemoryErrors or PermGen Space errors when running Grails in development mode. What do I do?

Since Grails 0.6, Grails automatically re-compiles Java sources and
domain classes using pre-compilation and then a server restart. This
can lead to permgen space running out if the server is run for a long
time and many changes are made. You can disable this feature if it is
not important to you with:

grails -Ddisable.auto.recompile=true run-app

There is also a problem with Grails 0.6 on Windows where you get
OutOfMemoryErrors during a period of activity in development mode due
to the re-compilation. This may be solved in SVN head, but if you see
this problem the above option can also help.

Easiest just to restart your application server when it happens.

药祭#氼 2024-11-23 01:32:58

在STS IDE中设置如下:

-XX:MaxPermSize=512m -XX:PermSize=128m

在此处输入图像描述

我希望它有所帮助。

In the STS IDE set as per following:

-XX:MaxPermSize=512m -XX:PermSize=128m

enter image description here

I hope it helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文