Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase heap memory for 'gradle test'

I have a problem running 'gradle test' against my Spring Boot application as I see signs of GC called too many times and my tests fail likely due to delays caused by agressive GC work.

How I can tell gradle to use more heap memory allowed for JVM during test phase, or in general?

like image 757
onkami Avatar asked Oct 10 '18 06:10

onkami


1 Answers

You can use the maxHeapSize configuration of the Test task.

Example in Gradle/Groovy:

test {   minHeapSize = "128m" // initial heap size   maxHeapSize = "512m" // maximum heap size   jvmArgs '-XX:MaxPermSize=256m' // mem argument for the test JVM } 

Or the same in Kotlin:

withType<Test> {   minHeapSize = "512m"   maxHeapSize = "1024m"   jvmArgs = listOf("-XX:MaxPermSize=512m") } 

Check out the official docs for additional info.

like image 108
miskender Avatar answered Sep 19 '22 20:09

miskender