Error:java.lang.OutOfMemoryError: Java heap space .

Error:java.lang.OutOfMemoryError: Java heap space .

Problem:

Error:java.lang.OutOfMemoryError: Java heap space . Please assign more memory to Gradle in the project’s gradle.properties file. For example, the following line, in the gradle.properties file, sets the maximum Java heap size to 1,024 MB: org.gradle.jvmargs=-Xmx1024m Read Gradle’s configuration guide
Read about Java’s heap size

 

Solution:

 

Open gradle.properties file from your project tree add this line at the memory allocation line

org.gradle.jvmargs=-XX\:MaxHeapSize\=256m -Xmx256m

or

org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m

or

org.gradle.jvmargs=-XX\:MaxHeapSize\=1024m -Xmx1024m

or

org.gradle.jvmargs=-XX\:MaxHeapSize\=1024m -Xmx2048m

or

org.gradle.jvmargs=-XX\:MaxHeapSize\=1024m -Xmx4096m

or

org.gradle.jvmargs=-XX\:MaxHeapSize\=1024m -Xmx8192m

Depending on the Memory of your computer. Then

Invalidate Caches/Restart project from the File > Invalidate Caches/Restart

To clean up your gradle cache and implement your new heap size memory changes

Leave a Reply

Your email address will not be published. Required fields are marked *