当我使用gradle 6.0构建多模块java项目时,当我添加〉30个模块时。抛出此错误:
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
我试图在我的$HOME/.gradle/gradle.properties
中添加什么参数:
org.gradle.jvmargs=-Xmx8096m -XX:MaxPermSize=8096m -XX:+HeapDumpOnOutOfMemoryError
可是问题没有解决,我该怎么办才能解决呢?
3条答案
按热度按时间ujv3wf0j1#
我将gradle.properties文件添加到我的根项目目录中,并添加以下配置:
从错误消息中,我们可以知道守护程序JVM空间已耗尽。这是关于此配置的Gradle official docuemnt:
指定用于Gradle守护程序的JVM参数。该设置对于配置JVM内存设置以提高构建性能特别有用。这不会影响Gradle客户端VM的JVM设置。默认值为-Xmx 512 m“-XX:MaxMetaspaceSize= 256 m”。
ffscu2ro2#
请注意,如果您由于某种原因无法修改
gradle.properties
文件(例如,我修改了gitlab-ci.yml
文件的脚本,以解决无法在本地重现的CICD管道问题),您可以使用命令行标记(带有-D
前缀),如上面的“官方文档”中@海豚所引用的。wa7juj8i3#
也许它也会帮助其他用户。
当我在
android
目录上执行gradlew clean
时,我收到了这个错误,并且忘记了返回cd ..
,我在android
目录内运行了启动应用程序的命令,而它不应该运行。解决方案是从
android
目录返回并在应用的根目录中运行start命令。