我在针对我的Spring Boot应用程序运行'gradle test'时遇到问题,因为我看到GC调用的次数太多次,而且我的测试很可能由于GC工作激增而导致延迟。
我如何告诉gradle在测试阶段或一般情况下使用JVM允许的更多堆内存?
您可以使用maxHeapSize
配置Test任务。
例:
test{
...
minHeapSize = "128m"
maxHeapSize = "512m"
}
// minHeapSize is for initial heap size.
// maxHeapSize is for maximum heap size.
// Increasing minHeapSize makes jvm start with a bigger heap at the start.
// Increasing maxHeapSize enables jvm to allocate more memory for its heap.
查看文档以获取更多信息https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html