Insufficient memory for Java Runtime Environment to continue when running Spotbugs in GitLab

I have an issue when running SpotBugs in GitLab CI environment where I get the an error which occurs from Insufficient memory for Java Runtime Environment. I am using a shared runner to execute this job and I’ve tried increasing the memory allocation (in my YML file) JAVA_OPTS: -Xmx6g but it still give the same error.
Is there something I’m missing or doing wrong, and are there any other solutions?

Most likely you exceeded the runner limits, see this post:

If the runner has 4gb limit, then you can’t exceed that - if using - otherwise you can install and configure your own runners and connect them to or your own Gitlab instance if you are running it.

EDIT: new link from the docs: SaaS runners on Linux | GitLab

So your only real option is create your own runner with sufficient memory resources and connect it to or your own Gitlab instance: Install GitLab Runner | GitLab and if using you can disable shared runners to force your project to use your own personal runner.

1 Like

The machine where the current runner that I’m using has 180GB, shouldn’t the runner have all that memory allocated (if needed)?

You may need to configure memory limits, are you using Docker?

Maybe by default just installing a runner isn’t enough unless configured otherwise. Never tried it, but that looks like it could be the reason why if it is a runner that you have installed yourself. There are a number of memory options that can be configured.

Yes, I’m using a Docker.

So, as per the docs I linked, you most likely need to be looking at your /etc/gitlab-runners/config.toml and from the example config in the link I provided:

  memory = "128m"
  memory_swap = "256m"
  memory_reservation = "64m"

to look at adding something similar to that to your existing config. Change the values accordingly based on the memory config of your server/vm that has gitlab-runner installed.

To be honest, the docs don’t state if there is a default limit or not, but that is all the info I can find that might help.

Sorry for bothering so much, but is the /etc/gitlab-runners/config.toml file does not appear when I’m searching for it (I am working on Mac).

I suppose it depends how your runner was installed, I assume you did it like the docs and run the runner on your Mac yes? Install GitLab Runner on macOS | GitLab