Molinho
Molinho

Reputation: 31

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

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.

Upvotes: 1

Views: 11444

Answers (5)

Flat Screen
Flat Screen

Reputation: 62

Press Ctrl+Enter to run highlighted section in android studio.

Upvotes: 0

YuvrajsinhJadeja
YuvrajsinhJadeja

Reputation: 1422

add this line into gradle.properties

org.gradle.jvmargs=-Xmx1536m

then clean and rebuild project

Upvotes: 1

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

Upvotes: 0

zingh
zingh

Reputation: 426

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.

Upvotes: 1

Homan Huang
Homan Huang

Reputation: 433

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

Upvotes: 1

Related Questions