Grails PermGem error

前端 未结 4 1974
执念已碎
执念已碎 2021-01-01 04:34

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.         


        
相关标签:
4条回答
  • 2021-01-01 04:35

    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

    0 讨论(0)
  • 2021-01-01 04:41

    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.

    0 讨论(0)
  • 2021-01-01 04:44

    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.

    0 讨论(0)
  • 2021-01-01 04:56

    In the STS IDE set as per following:

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

    I hope it helps.

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