Sonarcloud Bitbucket pipline failing due to exceeded memory limit

We have a project that uses SonarCloud and is hosted as a private repository on Bitbucket (w/ Premium plan).
When I kick off manual analysis from my PC everything works as intended.
Analysis takes about 15 minutes as our project is large (>500K LOCs) and at the end I get:

09:36:29.693 INFO: ------------------------------------------------------------------------
09:36:29.693 INFO: ------------------------------------------------------------------------
09:36:29.693 INFO: Total time: 15:45.021s
09:36:29.915 INFO: Final Memory: 43M/856M
09:36:29.915 INFO: ------------------------------------------------------------------------

My next step was to move analysis as a custom (manual) step for Bitbucket Piplines.
Our pipeline is configure as per docs and following example project here:

However every time I attempt to run the pipleline, it fails with following message:
Container 'docker' exceeded memory limit.

The output in the pipeline abtruptly stops with last line being
INFO: 58/2397 files analyzed, current file: REDACTED

Up to that point, analysis log matches the one generated by manual analysis…

According to the docs each pipeline step has 4GB limit, with option to increase it to 8GB using config option (size: 2x).

  • I tried increasing pipeline memory size to 8GB and I got the same error…
  • I also tried using SONAR_SCANNER_OPTS="-Xmx512m" (along with 8GB double memory pipeline) and got the same error…

Can someone please suggest if it is possible to fix this?


This issue is resolved.
The problem was not in the amount of memory for the step itself…
It was for the Docker process. By default, it is allocated only 1024 MB or memory and for some reason that is not enough in this case. I am not sure why though, but the following link explains how to increase Docker memory