Michael Paus
06/11/2023, 8:01 AM512m
of memory? All my configuration attempts seem to be consistently ignored. I added -Xmx4096m
to the runtime configuration of the test, org.gradle.jvmargs=-Xmx4g
to gradle.properties and more but my test always ends with an OutOfMemoryError which is no surprise because a printout like this inside the test code
val env = Runtime.getRuntime()
println("Max Heap Size = maxMemory() = " + env.maxMemory()) //max heap size from -Xmx, i.e. is constant during runtime
always tells me that the test is running with just 512m
. I have the feeling that this 512m
limit is somewhere just hard coded and overwrites all external settings. Is that possible?Oliver.O
06/11/2023, 9:54 AMtasks.withType<Test>().configureEach {
maxHeapSize = "8G"
}
Michael Paus
06/11/2023, 10:02 AMOliver.O
06/11/2023, 10:37 AMorg.gradle.jvmargs
just configures the Gradle build. A test task spawns a separate JVM which uses its own configuration.Michael Paus
06/11/2023, 10:50 AMOliver.O
06/11/2023, 11:07 AMOliver.O
06/11/2023, 11:41 AMGradle executes tests in a separate ('forked') JVM, isolated from the main build process. This prevents classpath pollution and excessive memory consumption for the build process. It also allows you to run the tests with different JVM arguments than the build is using.The IntelliJ documentation is somewhat vague, talking about VM options being "passed to the Java virtual machine when launching the application". In this case, "launching the application" probably means "invoking Gradle", so it would always configure just the Gradle build, never an out-of-process test execution.
Michael Paus
06/11/2023, 12:53 PMOliver.O
06/11/2023, 1:47 PMapplication
plugin says that its run
task will
launch a new JVM with its classesSo the IntelliJ IDEA doc could be more specific to account for typical Gradle JVM use cases.