为'gradle test'增加堆内存

问题描述 投票:6回答:1

我在针对我的Spring Boot应用程序运行'gradle test'时遇到问题,因为我看到GC调用的次数太多次,而且我的测试很可能由于GC工作激增而导致延迟。

我如何告诉gradle在测试阶段或一般情况下使用JVM允许的更多堆内存?

gradle jvm build.gradle
1个回答
5
投票

您可以使用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

© www.soinside.com 2019 - 2024. All rights reserved.