Gradle build fails with Out of Memory: Java heap space error
文章推薦指數: 80 %
Give more RAM for gradle org.gradle.jvmargs=-Xmx4g; If you face the same problem after can run for a few times, open Task Manager , End task ...
Home
Public
Questions
Tags
Users
Companies
Collectives
ExploreCollectives
Teams
StackOverflowforTeams
–Startcollaboratingandsharingorganizationalknowledge.
CreateafreeTeam
WhyTeams?
Teams
CreatefreeTeam
Collectives™onStackOverflow
Findcentralized,trustedcontentandcollaboratearoundthetechnologiesyouusemost.
Learnmore
Teams
Q&Aforwork
Connectandshareknowledgewithinasinglelocationthatisstructuredandeasytosearch.
Learnmore
GradlebuildfailswithOutofMemory:Javaheapspaceerror
AskQuestion
Asked
2yearsago
Modified
7monthsago
Viewed
17ktimes
9
Iamgettinggradlebuilderrorwhilerunningtheapp.Iamusingwindows10with8GBRAM,Androidstudioversion4.0.1
Outofmemory:Javaheapspace.PleaseassignmorememorytoGradlein
theproject'sgradle.propertiesfile.Forexample,thefollowingline,
inthegradle.propertiesfile,setsthemaximumJavaheapsizeto
1,024MB:org.gradle.jvmargs=-Xmx1024m
EvenafterfollowingthesamestepsIamnotabletoruntheapp.Couldanyonehelpwithapermanentsolutionforthiserror???
Hereismygradle.propertiesfile:
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1024m
androidandroid-studiogradleout-of-memorygradle.properties
Share
Improvethisquestion
Follow
editedDec8,2021at14:25
zb226
8,71166goldbadges4545silverbadges7474bronzebadges
askedJul25,2020at12:06
KartikaVijKartikaVij
31322goldbadges33silverbadges1515bronzebadges
3
Canyoutellmewhichosyouusing?(Windows/Mac...)howmanyGBofRAMyouhave?Andshareyourprojectgradle.propertiesplease
– ThuanTang
Jul25,2020at12:51
Ihaveeditedmyquestion
– KartikaVij
Jul25,2020at13:00
Takealookatthisstackoverflow.com/questions/39547100/…
– sajjad
Jul25,2020at13:08
Addacomment
|
4Answers
4
Sortedby:
Resettodefault
Highestscore(default)
Trending(recentvotescountmore)
Datemodified(newestfirst)
Datecreated(oldestfirst)
7
GivemoreRAMforgradleorg.gradle.jvmargs=-Xmx4g
Ifyoufacethesameproblemaftercanrunforafewtimes,openTaskManager,EndtaskanyOpenJDKPlatformbinaryorJava(TM)SeBinarytoreleaseRAM,thenyoucanrunprojectagain.
Ifyourcomputerhavelessthan8GBRAM,setlikethisinyourgradle.propertiesorg.gradle.jvmargs=-Xmx2048M
Share
Improvethisanswer
Follow
answeredJul25,2020at13:06
ThuanTangThuanTang
12155bronzebadges
0
Addacomment
|
3
Ifacedthesameissueinmy"react":"17.0.2","react-native":"0.66.1"project
Gotoproject/android/gradlew.properties
&uncommentthisline
#org.gradle.jvmargs=-Xmx2048m-XX:MaxPermSize=512m-XX:+HeapDumpOnOutOfMemoryError-Dfile.encoding=UTF-8
andonlychangethecodebeforecolan(:)org.gradle.jvmargs=-Xmx2048m-XX:MaxPermSize=512m-XXtoorg.gradle.jvmargs=-Xmx3g-XX:MaxPermSize=512m-XX
thensaveandrunyourbuild
Share
Improvethisanswer
Follow
answeredNov23,2021at15:37
abhishabhish
11711silverbadge55bronzebadges
Addacomment
|
2
I'mworkingonabigandroidprojectwithmultiplemodulesandflavorsandhadthesameproblem.
Itriedeverythingfromtweakingmemorytocleaningproject,restartingwhileinvalidatingcache,deletingsourcesandrecloningfromrepo.
Iendedupdeletingthe".gradle"folderinmyuserfolderandrecloningmyproject..anditworked.Lostalotoftimeonthisthough.
Share
Improvethisanswer
Follow
answeredSep15,2020at10:15
AlexMokAlexMok
72455silverbadges1818bronzebadges
Addacomment
|
-1
Addingandroid:largeHeap="true"totheAndroidManifest.xmlmaysolveyourproblem,ifyouhaven'talreadyadded.Butnotethatthemainissueisyourappisconsumingtoomuchmemory.Considertrackingyourappatruntimetofindtheunusualmemoryconsumingprocess/objects.
延伸文章資訊
- 1Error: Exception in thread "Daemon health stats" java.lang ...
SonarQube is failing with a Java Heap Size Out of Memory. Task :sonarqube FAILED ... .java:173) a...
- 2How to increase maximum heap size for the Gradle daemon?
- 3JVM / IR: "OutOfMemoryError Java heap space" during
I enabled the new backend in my project and tried a clean build. After a minute and a half of com...
- 4gradle Tutorial => Tuning JVM Memory Usage Parameters for Gradle
- 5Gradle Java project: java.lang.OutOfMemoryError - Snyk Support
Gradle Java project: java.lang.OutOfMemoryError: Java heap space. While testing a large Gradle Ja...