Could not reserve enough space for 1572864KB object heap Android Studio

天涯浪子 提交于 2021-02-07 10:13:40

问题


So I don't know what I clicked on but after I did, everything, like literally everything stopped working.

Current error message:

ERROR: Unable to start the daemon process. This problem might be caused by incorrect configuration of the daemon. For example, an unrecognized jvm option is used. Please refer to the User Manual chapter on the daemon at https://docs.gradle.org/5.4.1/userguide/gradle_daemon.html Process command line: C:\Program Files (x86)\Java\jdk1.8.0_181\bin\java.exe -Xmx1536m -Dfile.encoding=windows-1252 -Duser.country=NL -Duser.language=nl -Duser.variant -cp C:\Users\MSahl.gradle\wrapper\dists\gradle-5.4.1-all\3221gyojl5jsh0helicew7rwx\gradle-5.4.1\lib\gradle-launcher-5.4.1.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 5.4.1 Please read the following process output to find out more: ----------------------- Error occurred during initialization of VM Could not reserve enough space for 1572864KB object heap

Even after uninstalling everything the problem still persists.


回答1:


Open gradle.properties:
Max limit from Gradle 5.4.1 document:
If the requested build environment does not specify a maximum heap size, the Daemon will use up to 512MB of heap.

org.gradle.jvmargs=-Xmx512m
Or you can remark memory setting. The system will set by itself.

The rest of content of my file:
======================================================================
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
======================================================================
Now, File >> Sync Project with Gradle Files




回答2:


add this line into gradle.properties

org.gradle.jvmargs=-Xmx1536m

then clean and rebuild project




回答3:


My Android Studio was working fine. But executing Gradle from command line gave this same error 'could-not-reserve-enough-space-for-1572864kb-object-heap'

Looks like, it was because Gradle couldn't find java

Defined JAVA_HOME system variable, pointing to the same path Android studio was using. (get it from Studio > project structure > SDK Location > JDK Location)

Worked for me.




回答4:


restoring my system to an earlier date resolved the issue. it was an update to the jdk the cause



来源:https://stackoverflow.com/questions/58169350/could-not-reserve-enough-space-for-1572864kb-object-heap-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!