java.lang.OutOfMemoryError: Java heap space "issue"

Dear friends,
I have integrated the sonarcloud with my AWS Codepipeline to scan a PHP project. The scan works fine until it reaches “Running Tarjan” stage and then it fails. Here is the error log:

INFO: Reading UCFGs from: /codebuild/output/src846454926/src/.scannerwork/ucfg2/php
946 INFO: 08:28:51.190832 Running Tarjan on 301706 nodes
947 INFO: 08:28:52.22406 Tarjan found 297825 components
948 INFO: 08:28:53.615 Variable type analysis: done
949 INFO: 08:28:53.617751 Building Runtime Type propagation graph
950 INFO: 08:28:58.52339 Running Tarjan on 388006 nodes
951 INFO: 08:29:04.252782 Tarjan found 384190 components
952 INFO: 08:29:29.460727 Variable type analysis: done
953 INFO: 08:29:29.464429 Building Runtime Type propagation graph
954 INFO: 08:29:49.987287 Running Tarjan on 381384 nodes
955 INFO: ------------------------------------------------------------------------
957 INFO: ------------------------------------------------------------------------
958 INFO: Total time: 16:54.485s
959 INFO: Final Memory: 127M/427M
960 INFO: ------------------------------------------------------------------------
961 ERROR: Error during SonarScanner execution
962 java.lang.OutOfMemoryError: Java heap space
963 at com.sonar.C.A$_B.B(na:3359)
964 at com.sonar.C.A$_B.A(na:600)
965 at com.sonar.C.A$_B.(na:190)
966 at com.sonar.C.A$_B.(na:740)

Could someone please tell me what actually the issue is? may I need to disable some rule on the quality profile???

Thank you very much in advance

Hello @mohsin-integratech,

Thank you for your inquiry.
Can you share with us how much memory you have allocated to the analysis task?
The step ‘Running Tarjan’ is one part of our security analysis of your PHP project. The security analysis needs more memory than the code quality analysis depending on the size of your project.
If your pipeline setting does not provide enough memory, then try to increase this value.
Alternatively, you can use the auto-scan for PHP projects on SonarCloud. This provides up to 7GB of memory.


Hi Nils,
Thank you very much for your response. I was already using 15GB memory on my AWS codebuild server, however, the build failed. My client’s code was more than 2GB’s and having 3.4 million code lines. So then I choosed highly available memory option (145 GB’s which is only available option after 15GB’s) on the codebuild and the build was succeeded.
Thank you once again for your response.
Kind regards
Mohsin Nisar

Hi @mohsin-integratech,

glad I could help you out. Indeed, your project is very large and requires a lot of memory. Still, I hope we don’t really need the 145GB. Maybe you can help us with that and find out how much the scan will use in the end. With these values we can estimate approximately how much memory we need on average for this size of application. This information can then help other users.

Also, I would appreciate it if you mark my previous reply as ‘Solution’, this will close the thread and other users with a similar problem can more easily see that this problem would be solved.


Hi again Nils,

So the complete statistics are, the code size is 2.8GB’s, 3.3 million code lines. I just checked the memory consumption on the AWS CodeBuild server, it shows a maximum of 15.6 GB’s were consumed. Before this successful build, my Build server memory was 15 GB’s, and my build got failed. Another available option on AWS CodeBuild was only 145 GB’s so I Selected that. The conclusion is that 16-18 GB of memory was enough for this size of code.

Kind regards
Mohsin Nisar

Hi @mohsin-integratech,

thanks a lot for sharing these values. They will certainly help other users to better estimate the amount of memory to be allocated to a scan.


@Nils_Werner my pleasures

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.