我在Spring Boot应用程序上运行“渐变测试”时遇到问题,因为我看到GC调用的次数过多,并且测试可能由于积极的GC工作导致的延迟而失败。
在测试阶段或一般情况下,如何告诉gradle使用JVM允许的更多堆内存?
答案 0 :(得分:5)
您可以使用测试任务的maxHeapSize
配置。
示例:
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