SonarQube error GC overhead limit exceeded

When trying to run the SonarQube “Run Code Analysis” via Azure DevOps Server 2019.0.1, we are presented with the error of GC overhead limit exceeded.
I have done some googling and made the recommended changes to, these are the values I have set:
sonar.ce.javaOpts=-server -Xmx8192m -Xms512m -XX:+HeapDumpOnOutOfMemoryError

The Run Analysis still fails with this set, the code its is scanning is over 1 million lines and this is with excluding some file types.

SonarScanner for MSBuild 4.6.2

Additional logging:
2019-07-31T13:26:02.8509247Z ##[error]Exception in thread “Report about progress of Java XML analyzer” java.lang.OutOfMemoryError: Java heap space

2019-07-31T13:26:02.8511148Z Exception in thread “Report about progress of Java XML analyzer” java.lang.OutOfMemoryError: Java heap space

2019-07-31T13:26:02.8511838Z ##[error]at java.util.Arrays.copyOf(Unknown Source)
at java.lang.AbstractStringBuilder.ensureCapacityInternal(Unknown Source)
at java.lang.AbstractStringBuilder.append(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at Source)
2019-07-31T13:26:02.8513435Z at java.util.Arrays.copyOf(Unknown Source)
2019-07-31T13:26:02.8513825Z at java.lang.AbstractStringBuilder.ensureCapacityInternal(Unknown Source)
2019-07-31T13:26:02.8514124Z at java.lang.AbstractStringBuilder.append(Unknown Source)
2019-07-31T13:26:02.8514375Z at java.lang.StringBuilder.append(Unknown Source)
2019-07-31T13:26:02.8514638Z at
2019-07-31T13:26:02.8514874Z at Source)
2019-07-31T13:26:03.1657488Z INFO: ------------------------------------------------------------------------
2019-07-31T13:26:03.1658340Z INFO: EXECUTION FAILURE
2019-07-31T13:26:03.1658650Z INFO: ------------------------------------------------------------------------
2019-07-31T13:26:03.1663294Z INFO: Total time: 1:19:12.015s
2019-07-31T13:26:08.2439901Z INFO: Final Memory: 2252M/7002M
2019-07-31T13:26:08.2443761Z INFO: ------------------------------------------------------------------------

If you were just using the Scanner for MSBuild directly you could set the SONAR_SCANNER_OPTS environment variable as described in the troubleshooting section on the scanner docs page.

As you are run the build through an Azure Pipeline, you can set SONAR_SCANNER_OPTS as a pipeline variable and it will be passed through the scanner.

1 Like