javasonarqubeheap-memorybamboopermgen

Sonar java.lang.OutOfMemoryError: PermGen space


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?


Solution

  • 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.