Sonar gradle scan fails with java heap size

Hi
I have jenkins CI job with use gradle command for sonar scan. For one of my modules it keep throwing error of:

Exception in thread “pool-120-thread-1” java.lang.OutOfMemoryError: Java heap space
The Daemon will expire after the build after running out of JVM heap space.
The project memory settings are likely not configured or are configured to an insufficient value.
The daemon will restart for the next build, which may increase subsequent build times.
These settings can be adjusted by setting ‘org.gradle.jvmargs’ in ‘gradle.properties’.
The currently configured max heap space is ‘4 GiB’ and the configured max metaspace is ‘unknown’

any suggestions what to do? we already tried to adjust the java heap space from gradle level, but it didn’t help
Sonar Enterprise Edition v2025.1

Hi,

Can you try allocating more heap?

 
Ann

we tried and it didn’t help

Hi,

You should keep trying with increasingly large numbers.

 
HTH,
Ann

We tried with 10GB on gradle.properties and the issue still occurs. I can see this module has 1.5M lines of codes. maybe that could be the reason?

Hi,

That’s… a lot. Your best bet here is to try to break this up in chunks and analyze it as multiple, independent, non-overlapping projects.

 
HTH,
Ann

I tried to exclude the problematic path from the scan, but it didn’t help

Hi,

What “problematic path”? As I said,

 
HTH,
Ann

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