简体   繁体   English

IntelliJ IDEA Gradle 同步 OutOfMemory

[英]IntelliJ IDEA Gradle Sync OutOfMemory

I wonder how to increase heap size of Gradle Daemon process that IntelliJ IDEA uses to Sync project?我想知道如何增加 IntelliJ IDEA 用于同步项目的 Gradle Daemon 进程的堆大小?

Current process uses -Xms256m -Xmx512m当前进程使用-Xms256m -Xmx512m

I've already changed gradle-wrapper.properties file to:我已经将 gradle-wrapper.properties 文件更改为:

distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
org.gradle.jvmargs=-Xms4g -Xmx4g -XX:MaxPermSize=2048m

My IntelliJ IDEA settings:我的 IntelliJ IDEA 设置: 在此处输入图片说明 在此处输入图片说明

The file gradle-wrapper.properties is for the wrapper scripts only.文件gradle-wrapper.properties仅用于 包装器脚本 The org.gradle.jvmarg option doesn't belong in there. org.gradle.jvmarg选项不属于那里。

Rather, put it in a gradle.properties file in the project root directory.而是将其放在项目根目录中的gradle.properties文件中。 See here for more information.请参阅此处了解更多信息。

Also be aware that XX:MaxPermSize is not supported since Java 8.另请注意,自 Java 8 起不支持XX:MaxPermSize

Lastly, you may need to also raise the heap used by IntelliJ itself.最后,您可能还需要提升 IntelliJ 本身使用的堆。 Check the current usage by right-clicking on the status bar and select Memory Indicator:通过右键单击状态栏并选择内存指示器来检查当前使用情况:

在此处输入图片说明

Notice the current and max heap in the bar to the right.注意右侧栏中的当前和最大堆。 If it is close to full, you can change the heap size under Help -> Change Memory Settings:如果接近满,您可以在 Help -> Change Memory Settings 下更改堆大小:

在此处输入图片说明

The memory settings you showed is for the IntelliJ compiler.您显示的内存设置适用于 IntelliJ 编译器。 But as you can see from the Gradle settings you also showed, you delegate the build to Gradle.但正如您从还显示的 Gradle 设置中看到的,您将构建委托给 Gradle。 So this has no effect.所以这没有效果。

you can try this to give more heap memory to IntelliJ.您可以尝试使用方法为 IntelliJ 提供更多堆内存。

Hope you question is resolved.希望你的问题得到解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM