We’ve configured our project with Sonarqube on our yml file. Basically, we’ve encountered an issue with gradle daemon crash. Provided is the screenshot of our workflow.
With or without ./gradlew :app:assembleApiRelease --stacktrace line, ./gradlew build sonarqube --info throws the same error. See image below.
And here is our jvm args from gradle properties.
org.gradle.jvmargs=-Xmx4096M -Dkotlin.daemon.jvm.options=“-Xmx8192M” -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError
Your help is greatly appreciated. Thank you!
1 Like
Colin
(Colin)
February 22, 2022, 10:42am
2
Hey there.
Is there any more information regarding at what point in the build/analysis it crashes? Any INFO
level log lines (or DEBUG
if you switch logging to --debug
)? If it’s not something obvious, let us know and I’ll open a private message where you can share.
Hi Colin, Can’t see anything obvious on the logs (both INFO and DEBUG). Can we have this on private message?
I’m getting out of memory exception on a large multi module gradle project, what are optimal setting for this to run within github actions? I couldn’t find out how to easily increase memory available in github actions. Thanks!
Shudy
(Elias Ortiz)
March 21, 2023, 9:50am
5
Hii!
this topic is 5 months old, but In our project we are having this problem.
Our project is an Android multi-module. Is quite big.
In some PR’s the daemon disappear, and there is no “logic” behind . I mean, can disappear also in Big PR’s, as in small ones.
Our config is:
org.gradle.jvmargs=-Xmx5g -XX:MaxPermSize=3g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options=-Xmx5g
this Runs in a Github Runner: Ubuntu → 4 core and 16 Ram
Colin
(Colin)
March 22, 2023, 4:00pm
6
Hey all.
I found this issue on Gradle’s side:
opened 01:00PM - 28 Jan 22 UTC
in:daemon
a:bug
When investigating reports of "daemon disappeared" in GitHub Actions, and [a fea… ture request to address one cause](https://github.com/gradle/gradle-build-action/issues/122), it was found that the all of our DEFAULT_JVM8_ARGS are being lost as soon as _any_ value is set for `org.gradle.jvmargs`.
When `org.gradle.jvmargs` is not set by the user, then the daemon will start with default values [specified here](https://github.com/gradle/gradle/blob/6ccf8a2cc74c8060992bd36189dec929143caed7/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/configuration/DaemonParameters.java#L38-L39). But setting a value of `org.gradle.jvmargs` will overwrite these defaults, resulting in JDK defaults for `-Xmx`, `-Xms` etc.
One of the key defaults set by Gradle is `-XX:MaxMetaspaceSize=256m`, which is required because [this value is unbounded on the JDK by default](https://docs.oracle.com/en/java/javase/17/gctuning/other-considerations.html#GUID-B29C9153-3530-4C15-9154-E74F44E3DAD9), allowing the Gradle daemon to consume more and more native memory until it crashes.
This means that a user setting `org.gradle.jvmargs=-Xmx4g` can result in daemon crashes, unless the user knows that they must _also_ add a `-XX:MaxMetaspaceSize` setting.
In a similar way, the `-XX:+HeapDumpOnOutOfMemoryError` default is lost when a user specifies `org.gradle.jvmargs`.
### Expected Behavior
Important JVM defaults are not lost when a user sets unrelated JVM arguments.
### Current Behavior
Users must be aware of all important JVM argument defaults, and include all of these when setting any values for `org.gradle.jvmargs`.
### Context
This was discovered when investigating "daemon disappeared" issues in GitHub Actions workflows.
Here is an example of a build with such a failure: https://github.com/androidx/androidx/runs/4971463356?check_suite_focus=true#step:10:3845. No build scan was captured due to the nature of the failure.
Daemon log file for that CI run:
[gradle-daemon-logs_room.zip](https://github.com/gradle/gradle/files/7958782/gradle-daemon-logs_room.zip)
This part seemed important:
One of the key defaults set by Gradle is -XX:MaxMetaspaceSize=256m
, which is required because this value is unbounded on the JDK by default , allowing the Gradle daemon to consume more and more native memory until it crashes.
This means that a user setting org.gradle.jvmargs=-Xmx4g
can result in daemon crashes, unless the user knows that they must also add a -XX:MaxMetaspaceSize
setting.
@Shudy To start – can you try adding -XX:MaxMetaspaceSize=256m
?
1 Like
Shudy
(Elias Ortiz)
March 22, 2023, 5:04pm
7
Thank you very much @Colin , I find it disconcerting as well as interesting, that the basic configurations are deleted just by modifying a parameter.
I’ll make these changes, and I’ll be monitoring the GithubActions to see that it doesn’t keep happening.
I will inform you in a few days/week
Thanks!
1 Like
Shudy
(Elias Ortiz)
April 4, 2023, 10:06am
8
I’m back!
@Colin , as promised, We are now testing in GithubActions this new param in our gradle.properties. And everything is working fine.
Due to the size of our project, the memory assigned is quite bigger than 256m, but, works perfect.
Thanks!
1 Like
Colin
(Colin)
April 4, 2023, 11:59am
9
Hey @Tom_Wilson and @jayarbautista – if you’re still out there, maybe you can give this a try! It worked for @Shudy (thanks for the follow-up! )
1 Like