Reputation: 1440
I know that there are similar questions out here, but none seems to provide a solution, so I hope that my setting is somewhat different, so that there may be a solution at least for this specific problem:
For some reasons we are stuck to SonarQube 4.5.6 at the moment, trying to analyse a huge Java project (12.000 files with about 1.000.000 lines of code). The rule set consists of about 700 rules spread over the java-plugin (latest version 3.11), findbugs (latest version 3.3), checkstyle (need to use an older version here - 2.2, cause of some rules not available in later versions), and pmd (latest version 2.5).
With Sonar Runner 2.4 the parts of java-plugin, findbugs (with a timeout set to about 20 minutes), checkstyle run through, but within pmd I keep getting an OutOfMemoryError: PermGen space
17:56:31.276 INFO - Sensor PmdSensor...
17:56:31.279 INFO - Execute PMD 5.4.0...
17:56:31.313 INFO - Java version: 1.5
17:56:31.360 INFO - PMD configuration: C:\src\.\.sonar\pmd.xml
17:57:23.679 INFO - Execute PMD 5.4.0 done: 52400 ms
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 57:33.538s
Final Memory: 47M/3908M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.OutOfMemoryError: PermGen space
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at net.sourceforge.pmd.lang.java.typeresolution.PMDASMClassLoader.loadClass(PMDASMClassLoader.java:65)
at net.sourceforge.pmd.lang.java.typeresolution.ClassTypeResolver.populateType(ClassTypeResolver.java:655)
at net.sourceforge.pmd.lang.java.typeresolution.ClassTypeResolver.visit(ClassTypeResolver.java:179)
at net.sourceforge.pmd.lang.java.ast.ASTImportDeclaration.jjtAccept(ASTImportDeclaration.java:62)
at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:55)
at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:9)
at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:136)
at net.sourceforge.pmd.lang.java.typeresolution.ClassTypeResolver.visit(ClassTypeResolver.java:170)
at net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit.jjtAccept(ASTCompilationUnit.java:42)
at net.sourceforge.pmd.lang.java.typeresolution.TypeResolutionFacade.initializeWith(TypeResolutionFacade.java:17)
at net.sourceforge.pmd.lang.java.AbstractJavaHandler$5.start(AbstractJavaHandler.java:88)
at net.sourceforge.pmd.SourceCodeProcessor.usesTypeResolution(SourceCodeProcessor.java:127)
at net.sourceforge.pmd.SourceCodeProcessor.processSource(SourceCodeProcessor.java:142)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:76)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:43)
at org.sonar.plugins.pmd.PmdTemplate.process(PmdTemplate.java:82)
at org.sonar.plugins.pmd.PmdExecutor.executeRules(PmdExecutor.java:120)
at org.sonar.plugins.pmd.PmdExecutor.executePmd(PmdExecutor.java:90)
at org.sonar.plugins.pmd.PmdExecutor.execute(PmdExecutor.java:75)
at org.sonar.plugins.pmd.PmdSensor.analyse(PmdSensor.java:67)
The stack trace says I'm still in pmd, but the pmd seems to have already been through analysis (line Execute PMD 5.4.0 done: ...
), and there shouldn't be another plug-in running thereafter. Nevertheless, I wonder where I should increase the PermGen space ... I already have
wrapper.java.additional.2=-XX:MaxPermSize=8g
wrapper.java.maxmemory=8g
in wrapper.conf
and also tried to add
set JAVA_OPTS="-XX:PermSize=256m -XX:MaxPermSize=4096m"
in sonar-runner.bat
. In addition there's
sonar.web.javaOpts=-server -Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
in sonar.properties
. First, I don't understand which setting is the one responsible for the OutOfMemoryError
- the one in wrapper.conf
? the one in sonar-runner.bat
? or sonar.properties
?
What can I do when PermSize of 8g
isn't helping?? The default size is 128m
or something, so it's already a factor of 64!?
Any idea, how to analyse this project with SonarQube? The problem occurs as well with the built-in database as with a MySQL, so I don't think that that has any influence.
Any help appreciated. Thanks ... if you need any more info about configuration or have an idea to get some more infos out of some logs, please let me know.
Upvotes: 1
Views: 1822
Reputation: 22804
You need to allocate the extra memory not on the server side, but on the analysis side to the process that runs the analysis. Since you appear to be analyzing using the SonarQube Scanner, I'll direct you to the Troubleshooting section of those docs, where it tells you how to adjust the memory settings for the process by exporting a SONAR_RUNNER_OPTS
env var.
Upvotes: 3