I had a failing OOM unit test and wondered why I needed to manually allow for bigger maxHeapSize like so:
test {
maxHeapSize = '4G'
}
I assumed the max heap is not capped and couldn't find anything in gradle api sources to prove me wrong. However, running gradle with --info clearly reveals otherwise:
Starting process 'Gradle Test Executor 427'. Working directory: [project-dir] Command: /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/bin/java -Djava.security.manager=worker.org.gradle.process.internal.worker.child.BootstrapSecurityManager -Dorg.gradle.native=false -javaagent:build/tmp/expandedArchives/org.jacoco.agent-0.8.6.jar_a26f6511a7813217be4cd6439d66563b/jacocoagent.jar=destfile=build/jacoco/test.exec,append=true,inclnolocationclasses=false,dumponexit=true,output=file,jmx=false -Xmx512m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -ea -cp /Users/[user]/.gradle/caches/6.4/workerMain/gradle-worker.jar worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor 427'
My question is where does the -Xmx512m above come from?
Next to that, is there a way to allow for unlimited max heap and would that be a totally unreasonable thing to do?
possible duplicate of Default maximum heap size for JavaExec Gradle task