我在 Spring Boot 应用程序上运行“gradle 测试”时遇到问题,因为我看到 GC 调用次数过多的迹象,并且我的测试可能由于积极的 GC 工作造成的延迟而失败。
我如何告诉 gradle 在测试阶段或一般情况下使用更多的 JVM 允许的堆内存?
最佳答案
您可以使用 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
关于gradle - 为 'gradle test' 增加堆内存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52733942/