5

I am getting OutOfMemoryException while performing sonar analysis on my project. Jenkins job shows analysis report was generated successfully but during background task in SonarQube it is failing with below exception.,

2016.08.24 10:55:52 INFO  [o.s.s.c.s.ComputationStepExecutor] Compute comment measures | time=14ms
2016.08.24 10:56:01 INFO  [o.s.s.c.s.ComputationStepExecutor] Copy custom measures | time=9075ms
2016.08.24 10:56:02 INFO  [o.s.s.c.s.ComputationStepExecutor] Compute duplication measures | time=150ms
2016.08.24 10:56:34 ERROR [o.s.s.c.c.ComputeEngineContainerImpl] Cleanup of container failed
java.lang.OutOfMemoryError: GC overhead limit exceeded
2016.08.24 10:56:34 ERROR [o.s.s.c.t.CeWorkerCallableImpl] Failed to execute task AVa6eX7gdswG1hqK_Vvc
java.lang.OutOfMemoryError: Java heap space
2016.08.24 10:56:34 ERROR [o.s.s.c.t.CeWorkerCallableImpl] Executed task | project=iServe | id=AVa6eX7gdswG1hqK_Vvc | time=53577ms
Sri
  • 51
  • 1
  • 1
  • 5
  • Clearly it is running out of memory, you need to provide some sort of information about how much memory the system has and how much sonarqube is using before it crashes. – Magnus Aug 24 '16 at 03:48
  • Yes, i have increased memory opts for compute engine, Web source and Java as below but nothing helped. sonar.ce.javaOpts=-Xmx1024m -Xms128m – Sri Aug 24 '16 at 04:31

4 Answers4

3

I use docker-compose and this option works perfectly for me.

version: "2"

services:
  sonarqube:
    image: sonarqube
    command: -Dsonar.ce.javaOpts=-Xmx4096m

You can costumize the memory size.

Arief Karfianto
  • 235
  • 2
  • 8
2

I know this late, but might help someone :

Try to increase MaxPermSize

I have these configurations under respective JVM Options (web/ce/Elastic search) of sonar.properties file :-

sonar.web.javaOpts =-Xmx8512m -Xms512m -XX:MaxPermSize=1024m / sonar.ce.javaOpts =-Xmx8512m -Xms512m -XX:MaxPermSize=1024m / sonar.search.javaOpts =-Xmx8512m -Xms512m -XX:MaxPermSize=1024m

For me, it actually worked with '1024m', just because I had multiple modules in my project and just as a hint my server as well need same size for deployments.

whoami - fakeFaceTrueSoul
  • 17,086
  • 6
  • 32
  • 46
  • 2
    MaxPermSize is ignored in Java 8+ and actually issues a warning, which might break some builds https://stackoverflow.com/questions/18339707/permgen-elimination-in-jdk-8 – Novaterata Apr 16 '18 at 13:47
0

Hi i solved this problem in two ways for two different scenarios where i found this issue

  1. Case : when using jenkins :: I was also facing this problem some time ago, my sonar analysis worked fine on command line but it failedon jenkins, you can replace %SONAR_RUNNER_OPTS% with -Xms256m -Xmx1024m to increase the heap size in sonar-runner bat file.

  2. Case : when using command line :: i also got this errorsometimes when i was using cmd line to run sonar analysis , in which cas the solution is to create more number of modules, it somehow works and i dont get java out of mem error.

  3. For Linux systems : Edit ./sonar-scanner-2.6.1/bin/sonar-runner file and add

  SONAR_SCANNER_OPTS="$SONAR_SCANNER_OPTS -Xmx2048m -XX:MaxPermSize=1024m"
  **Note:- SONAR_RUNNER_OPTS is deprecated**.

  if [ -n "$SONAR_RUNNER_OPTS" ] ;
then
  echo WARN: '$SONAR_RUNNER_OPTS' is deprecated. Please use '$SONAR_SCANNER_OPTS' instead.

Hope it helps :)

Jeff Y
  • 2,437
  • 1
  • 11
  • 18
  • So i need to add this in sonar-runner.properties file right ? not in sonar.properties ? – Sri Aug 24 '16 at 04:37
  • Same issue., 2016.08.24 13:06:21 ERROR [o.s.s.c.c.ComputeEngineContainerImpl] Cleanup of container failed java.lang.OutOfMemoryError: GC overhead limit exceeded 2016.08.24 13:06:21 ERROR [o.s.s.c.t.CeWorkerCallableImpl] Failed to execute task AVa679P4xqcL0-osYQgv java.lang.OutOfMemoryError: Java heap space 2016.08.24 13:06:21 ERROR [o.s.s.c.t.CeWorkerCallableImpl] Executed task | project=ICALL | id=AVa679P4xqcL0-osYQgv | time=84848ms – Sri Aug 24 '16 at 05:07
  • 1
    You right click `bin/sonar-runner.bat ` and select edit, in that file you'll find %SONAR_RUNNER_OPTS%, set its value according what you may think should be enough and run the analysis. – Ashutosh Angiras Aug 24 '16 at 05:26
0

I encountered a similar issue and added -Xmx2048m -XX: MaxPermSize = 1024m in the JVM Options and the scanning process went smoothly.

Dov Benyomin Sohacheski
  • 7,133
  • 7
  • 38
  • 64
Trias Alvyn
  • 291
  • 2
  • 2
  • Where did you add those options? Did you change a config file, environment variables, or did you do it as a command line argument? – Jose B Sep 20 '17 at 15:14
  • 2
    in the JVM arguments while you want to do scanning job process – Trias Alvyn Sep 29 '17 at 08:35
  • 2
    MaxPermSize is ignored in Java 8+ and actually issues a warning, which might break some builds https://stackoverflow.com/questions/18339707/permgen-elimination-in-jdk-8 – Novaterata Apr 16 '18 at 13:33