SonarQube java.lang.OutOfMemoryError:超出GC开销限制

Sri*_*Sri 5 java sonarqube devops

我在OutOfMemoryException对我的项目进行声纳分析时得到了。Jenkins 作业显示分析报告已成功生成,但在后台任务期间SonarQube失败并出现以下异常。,

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
Run Code Online (Sandbox Code Playgroud)

小智 0

您好,我通过两种方式解决了这个问题,针对两种不同的场景,我发现了这个问题

  1. 案例:使用jenkins时::前段时间我也遇到了这个问题,我的声纳分析在命令行上运行良好,但在jenkins上失败了,您可以用-Xms256m -Xmx1024m替换%SONAR_RUNNER_OPTS%以增加sonar-runner中的堆大小.bat 文件。

  2. 案例:当使用命令行时::我有时也遇到这个错误,当我使用cmd行运行声纳分析时,解决方案是创建更多数量的模块,它以某种方式工作,并且我没有得到java out of mem错误。

  3. 对于 Linux 系统:编辑 ./sonar-scanner-2.6.1/bin/sonar-runner 文件并添加

  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.
Run Code Online (Sandbox Code Playgroud)

希望能帮助到你 :)