java.lang.OutOfMemoryError: Java heap space after upgrading to 10.8.1

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube Server / Community Build, Scanner, Plugin, and any relevant extension): SonarQube Server 10.8.1-enterprise
  • how is SonarQube deployed: Helm
  • number of projects: Around 2300
  • lines of code: Around 8.5M

We recently upgraded from 10.6 enterprise to 10.8.1 and started to see OutOfMemoryErrors straight away, where we had not seen problems previously.

We first saw problems during the database upgrade, which we resolved by specifying more memory for the heap using the SONAR_WEB_JAVAOPTS and SONAR_WEB_JAVAOPTS variables.

Following the upgrade, we could not see some projects in the UI, the SonarQube server was restarting and the logs were full of OutOfMemoryErrors.

After experimenting with various values for the SONAR_WEB_JAVAOPTS and SONAR_WEB_JAVAOPTS variables, we have found that -Xmx8G -Xms1G (the underlying resource is available to support this configuration) have made things stable for the most part but we still have these problems:

  • Anything to do with one particular project such as browsing the project in the UI or performing project analysis causes OutOfMemoryErrors. In the UI, the overview tab for this one project does not load any data (other tabs show data) and results in OutOfMemoryError in the log like this:

    Processing of request /api/project_branches/list?project=<PROJECT_ID> failed"
    java.lang.OutOfMemoryError: Java heap space
    

    Project analysis also fails with:

    ERROR ce[<TASK_ID>][o.s.c.t.CeWorkerImpl] Failed to execute task <TASK_ID>"
    java.lang.OutOfMemoryError: Java heap space
    

    This project has around 40K LoC and there are other, much larger projects (300K) where this issue is not encountered. I tried reindexing this project using the API but this did not help.

  • When calling the api/projects/license_usage API, we receive a 500 response and the same OutOfMemoryError is reported in the log:

    ERROR web[][o.s.s.p.w.RootFilter] Processing of request /api/projects/license_usage failedj
    ava.lang.OutOfMemoryError: Java heap space
    

I’m interested to find out what could be done to resolve the mentioned issues and why 10.8.1 seems to be so much more demanding than previous versions? I’m reluctant to add yet more memory unless I can understand why we need so much more memory only after this upgrade and how much I should be allocating, as I’ve already scaled up x8!

Thanks for your help in advance.

Hey there.

We made specific improvements with SONAR-24057 to address this issue. You should upgrade to v2025.1 LTA ASAP!