SonarCloud/qube out of memory even with higher heap size

Hello @Margarita_Nedzelska , could you please help me with this problem ?

Update:

I’ve discovered that we had a lot of failing tests in our codebase, so I’ve just ignored them, and added SonarCloud to the project again.

Received: Your analysis with ID “xxxxxxx” (I can provide it by DM) has failed: the analysis of your project exceeded the maximum memory available for Automatic Analysis.

Since I’ve sent the heap dump to @jbeleites and have no anwser, I’m posting here again…
We’re without sonar analysis since NOVEMBER.

I think this will be a good point to think when renewing with SonarCloud…

Hello Souza,

I’m sorry you are experiencing difficulties. Your situation is not completely clear for us and without a reproducer, we cannot easily pinpoint an issue. We give our best to help with the information you provide us, however be aware that this is the community and not commercial support. That means we cannot guarantee when we have the capacity to look into the issues you are facing. Although we will obviously try to help you, I recommend you consider commercial support if you are not satisfied with the help we can provide you via the community. In either case, we can only start looking into issues as soon as you send us the required information, such as a heap dump (and thanks for sending that my way a couple of weeks ago).

That being said, let’s have a look at where we are so far. I’ll try to summarize the important bits of information from this thread, please let me know if you feel some details are inaccurate or I have forgotten something.

  • The problem: when you scan your project, you encounter an OutOfMemoryError
  • You appear to be using SonarCloud, so the analyzers you are using are up-to-date. That’s good.
  • You have tried giving the analysis process up to 8GB of ram, it gets close to the end of the analysis but still fails.
  • I have had a look at the most recent heap dump and don’t see anything particularly out of the ordinary. In particular, I’ve not been able to find evidence that the Kotlin scanner is leaking memory.

How many lines of code does your project entail? From what you wrote earlier, I gather that the module the analysis fails on has 4209 files. That is not a small project. Depending on variables such as project size and number/size of dependencies, the analysis may simply require more than 8GB to run.

Do you have the possibility of running a local analysis and giving the process 16GB of RAM? Please test that and let us know how it goes. This may give us an indication in which direction we can continue looking for the underlying issue.

Hello Johann…
The problem is not reading the rules, I am totally sure that I am not being rude with anyone here, but you prefer giving me a badge instead of helping me.

My last analysis were running in eternal loop too, even if I ignore a lot of modules here… There’s something to do with Sonar… We can even run it by CI (bitrise) or Local… but on SonarCloud NO… I don’t think the problem is our project at this moment. Could you help us?

Obs: Locally or CI I can run sonarcloud even with the normal ram allocated (4gb)

@jbeleites @Margarita_Nedzelska

Is there any chance for you to increase the memory from sonarcloud? Because I can run the analysis locally without any problem… using 6 or 8g of ram

Hello Souza,

So far I canot see any indications of infinite recursions or loops. If there is too little memory available for the scanner to scan a particular project, the heap will eventually fill up to nearly 100%. At that time, execution will slow to a crawl, as nearly all computing resources are instead being used to garbage collect. This may seem like an infinite loop, since the program is running for a long time without making significant progress.

Since you can run the scan with Bitrise and locally (as long as you allocate enough available memory), this strongly suggests that the actual problem is the scan requiring more memory than you have available in the situations where the task fails. The heap dump you sent also shows no signs of infinite recursion.

My problem is that I have no idea what exactly you are doing and how, so it is extremely difficult to diagnose the exact problem. You will need to give us more details and ideally a way to reproduce the problem you are facing, otherwise we may continue guessing back and forth without solution for another six months.

So, for me to understand the current situation a bit better, please answer the following questions as precisely as possible:

  • From your post I understand that your analysis is successful if you run it with 4GB RAM locally or on Bitrise. Is that correct?
  • When you say that you are running the analysis “on SonarCloud” and it fails, how exactly are you running the analysis? What steps are you taking to trigger a new scan?

Hi Johann,

The first problem happened when SonarCloud just stopped to work without any explanation. It just stopped. So I made the first post about the analysis in loop/not ending.

At this time, I was running the automatic analysis, running on PRs.

After that:

  • I tried to delete the project on sonarcloud. X

  • ignored some modules using sonarcloud website, using .sonar.properties too, and run again. X

  • created a clone project on github and started the analysis deleting the files I said above. It worked ONLY if i delete almost all of my files. So what I did was: commit the revert (re-adding the deleted filed one module by one)… and worked until I added our biggest module. It failed again: 7b5f0d7e-021c-494d-ad02-503db1315477… this analysis was runned by the commit trigger (I just commited in my branch, and it runned the analysis.

In bitrise we have: -Xms4g -Xmx8g on java options… and it’s running normally with all modules.
Locally (in terminal) we can run it normally too.

Hi Souza,

Thanks for providing these pieces of information! They are helping a lot with our investigation, especially the autoscan ID. This allows us to look into why the task failed in more detail - which we are doing right now. We will be back with more information shortly.

Hey @kyle_gass

We looked into why Automatic Analysis failed. The issue comes from it being a very first analysis with a lot of SCM (git) data to load. This bottleneck in the analysis is something we’re looking to improve (in a matter of months), but in the meantime, you should be able to switch to CI-based analysis (it may take a while for the first run).

Based on your recent updates, it sounds like you currently have a working CI-based or local analysis, is that correct?

So it’s correct to say that you no longer face the issue described last summer?

Thanks!

Hello Johann and Colin,

I’m trying to run it by CI here, I will post here when I get a result (trying to solve our failing tests, like we can’t skip this task on sonarqube).

New analysis failing: AX91LRolsKpWwBsBYCoW (running the whole project too)

edit:
I just ran it by CI and got it working on the first analysis.
Once i did that, i’ve enabled the automatic analysis, and got the same error… AX914-X01EcK-654CHqZ
do you know what is going on?

Hey @kyle_gass

I think I understand a bit better now that this OutOfMemoryError is actually coming from the processing of the analysis that is submitted to SonarCloud.

Could you provide a screenshot of where you’re seeing the error in the SonarCloud UI? Is it under Administration > Background Tasks? I’m having trouble tracking down the UUIDs you’re providing (AX91LRolsKpWwBsBYCoW and AX914-X01EcK-654CHqZ) in the SonarCloud logs.

Admittedly, it’s getting a little confusing what the definition of success is here. To run it in your CI (which you say is working)? To run it in Automatic Analysis? I’m getting a bit lost, and I have a feeling that part of the issue could be trying to switch between them (although we should still understand the root cause of any OutOfMemoryError)

Hi Colin,
I cannot send a screenshot here since its a private project, but the analysis IDs that im sending to you are from
Main page → Click on PullRequests → click on any pull request analysis that is running, and after sometime, I get this message.

Clicking on Background tasks I only can get the main analysis of the main branch → AX910yHADWY2wrQIOaUt that was a success on Bitrise CI.

So tl;dr: I’ve ran the analysis (./gradlew sonarqube) on CI (turning the automatic analysis on offline on sonarcloud), and after that I have turned the automatic analysis online to run on my pullrequests and started to send me these error messages about the analysis fails.

Hey guys, could you help me ? I think we’re next to the problem solution

Hey @Colin, how are you? Could you please help me with this problem?

Hey @kyle_gass

I think part of the problem is that you are switching between Automatic Analysis and CI-Based Analysis, I think because you think that’s what needs to happen to analyze your pull requests.

In fact, what can you do is set sonar.pullrequest.key, sonar.pullrequest.base, and sonar.pullrequest.branch in your CI configuration when a Pull Request is being built (see here) by using environment variables with this information to use the right information for each build.

Hello @Colin, tried here, but nothing seems to work :confused:

Hey Kyle.

Unless you explain exactly what you tried, and what didn’t work (and how it didn’t work), unfortunately we really can’t help much.

@Colin I already explained everything since last year.
I tried everything you (from sonar) said to me to do, but nothing works.

I just want to know where the analysis is stuck… maybe the solution is to skip this module or anything like this… could someone please help me?