Daemon is stopping immediately JVM garbage collector thrashing and after running out of JVM memory

2022-09-02 00:33:30

When I build multi module java project using gradle 6.0,when I add >30 modules.Throw this error:

Gradle Daemon started in 2 s 267 ms

> Configure project :soa-misc
"/opt/dabai/tools/jdk1.8.0_211/jre/lib/ext/"
null
Expiring Daemon because JVM heap space is exhausted
Daemon will be stopped at the end of the build after running out of JVM memory
Expiring Daemon because JVM heap space is exhausted
Expiring Daemon because JVM heap space is exhausted
Expiring Daemon because JVM heap space is exhausted
Expiring Daemon because JVM heap space is exhausted
Expiring Daemon because JVM heap space is exhausted
Expiring Daemon because JVM heap space is exhausted
Expiring Daemon because JVM heap space is exhausted
Expiring Daemon because JVM heap space is exhausted
Expiring Daemon because JVM heap space is exhausted
Expiring Daemon because JVM heap space is exhausted
Expiring Daemon because JVM heap space is exhausted
Daemon is stopping immediately JVM garbage collector thrashing and after running out of JVM memory

What I am tried to add parameter in my :$HOME/.gradle/gradle.properties

org.gradle.jvmargs=-Xmx8096m -XX:MaxPermSize=8096m -XX:+HeapDumpOnOutOfMemoryError

But the problem not solved,what should I do to fix?


答案 1

I add gradle.properties file in my root project dir,and add this config:

org.gradle.jvmargs=-Xmx4096M

works. From the error message we can know the Daemon JVM spcace exhausted. This is the Gradle official docuemnt about this config:

Specifies the JVM arguments used for the Gradle Daemon. The setting is particularly useful for configuring JVM memory settings for build performance. This does not affect the JVM settings for the Gradle client VM. The default is -Xmx512m "-XX:MaxMetaspaceSize=256m".


答案 2

Maybe it will help other users as well.

I received, somewhat, this error when I did a on the directory and forgot to go back with and I run the command of starting the app inside directory when it shouldn't.gradlew cleanandroidcd ..android

The solution is to go back from directory and run the start command in the root directory of your app.android


推荐