Grails PermGem Error

I need help solving this problem. I need someone to explain to me why this is 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. 
+4
source share
4 answers

PermGen is the area of ​​your JVM memory that is used to load classes.

As soon as the application runs, it uses more and more of this memory, especially if you are in a debugging environment, if you use closure extensively.

To fix it, add it more!

This is done by passing one or two JVM parameters at application startup.

Options:

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

(adjust the values ​​for your specific needs)

PermSize will be the initial size of PermGen, and MaxPermSize will be the maximum size it will increase before throwing an exception to you, as in your message.

By default, it is set to 64M , which is not enough if you have a "real" application.

ATTENTION: Your total memory usage will be: Heap size + Perm Size

+19
source

If you are using a servlet version 3.0, then even increasing your memory will not have any help, since this is a problem with the groovy compiler. The new version 1.8.2 / 1.9 (?), Which will be released in the near future, will solve this problem. In the meantime, you can change the servlet version to "2.5" (in BuildConfig.groovy), which will solve this problem.

The disadvantage of changing the servlet version to version 2.5 is that it cannot be deployed to the Glassfish application server, so the ugly workaround changes to 2.5 and uses a "run-app". When you want to deploy to a glass grid, change the servlet version to “3.0” in BuildConfig.groovy, launch “war”, and then deploy the war to Glassfish. Change it to "2.5" to run it again on the local machine.

+1
source

Check FAQ

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

Starting with Grails 0.6, Grails will automatically recompile Java sources and domain classes using precompilation and then restarting the server. This can lead to the fact that the space with the pergene will be exhausted if the server is working for a long time and a lot of changes. You can disable this feature if it is not important to you:

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

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

The easiest way is to simply restart the application server when this happens.

0
source

In STS, the IDE is set as follows:

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

enter image description here

Hope this helps.

0
source

All Articles