Sonar java.lang.OutOfMemoryError: PermGen space

血红的双手。 提交于 2019-12-23 03:22:25

问题


I'm getting the following error when running a build in ant

buildcallbacks.xml:39: org.sonar.runner.RunnerException: java.lang.OutOfMemoryError: PermGen space

It's the part of the build where sonar runs over our code.

Is there a way for me to know exactly where this error is coming from i.e is it the sonar server or the client etc ?

Here is line 39 of my buildcallbanks.xml

<sonar:sonar />

EDIT: I've tried increasing the permsize from the wrapper.conf within Sonar and I still get the same issue no matter how high I set it. I must still be missing something?


回答1:


I actually went back to look at this after you - it was still failing. You were nearly there but I found two things:

  1. You had used JAVA_OPTS instead of ANT_OPTS
  2. CMSClassUnloadingEnabled is only used if you also use UseConcMarkSweepGC. See here: CMSPermGenSweepingEnabled vs CMSClassUnloadingEnabled

So the settings that seem to be working a treat now are:

ANT_OPTS="-Xmx1024m -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:MaxPermSize=512m"

UPDATE: Years later I have actually re-visited this again as the problem reoccurred. You don't actually need to mess with the GC settings, just the memory. The correct options to use are in fact:

ANT_OPTS="-Xmx2G -XX:MaxPermSize=1G"

Obviously you can tweak the memory values to suit your machine.

Hope this helps others.




回答2:


This error is not caused by any specific line of code, so there would be no point in trying to locate it. You'll just have to reconfigure the Java runtime that ant uses so that the limit on the PermGen space is increased. This wiki page documents how to achieve this. Basically, you set the ANT_OPTS environment variable.




回答3:


Instead of increasing the heap size, try increasing the permgen size. You can do this with

ANT_OPTS=-XX:MaxPermSize=128m

The default size is 64 MB, so this setting should double the maximum memory available.

The PermGen memory is used for things that don't change often while running the JVM, like class definitions.




回答4:


Increasing the permspace on the sonar server didn't seem to have any effect.

This issue seems to have been caused by running too many ant targets at the 'assembly' stage in Bamboo. I am now running 'clean all production' followed by a call to the ant sonar plugin .jar.

It also seems that classes weren't being unloaded when they should have been. This was fixed with the following JVM parameter: -XX:+CMSClassUnloadingEnabled



来源:https://stackoverflow.com/questions/13175668/sonar-java-lang-outofmemoryerror-permgen-space

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!