我有一个包含大约 500-700 个测试的应用程序,我需要使用运行这些测试
./gradlew clean build
一些测试会带来上下文。无论我尝试多少次更改 build.gradle 中 gradler 测试的设置,测试都会失败并出现错误
OutOfMemory
,初步日志显示以下内容:
[303.647s][warning][gc,alloc] ClassGraph-worker-2318: Retried waiting for GCLocker too often allocating 256 words
[303.647s][warning][gc,alloc] ClassGraph-worker-2321: Retried waiting for GCLocker too often allocating 256 words
[344.100s][warning][gc,alloc] ClassGraph-worker-2311: Retried waiting for GCLocker too often allocating 65536 words
[344.100s][warning][gc,alloc] ClassGraph-worker-2319: Retried waiting for GCLocker too often allocating 256 words
[346.936s][warning][gc,alloc] ClassGraph-worker-2311: Retried waiting for GCLocker too often allocating 21586 words
[346.936s][warning][gc,alloc] ClassGraph-worker-2312: Retried waiting for GCLocker too often allocating 256 words
[346.936s][warning][gc,alloc] ClassGraph-worker-2304: Retried waiting for GCLocker too often allocating 2750 words
[347.159s][warning][gc,alloc] ClassGraph-worker-2327: Retried waiting for GCLocker too often allocating 9370 words
[347.163s][warning][gc,alloc] ClassGraph-worker-2315: Retried waiting for GCLocker too often allocating 256 words
[347.163s][warning][gc,alloc] ClassGraph-worker-2323: Retried waiting for GCLocker too often allocating 256 words
[347.170s][warning][gc,alloc] ClassGraph-worker-2322: Retried waiting for GCLocker too often allocating 256 words
[347.410s][warning][gc,alloc] ClassGraph-worker-2310: Retried waiting for GCLocker too often allocating 256 words
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "FeignApacheHttpClientConfiguration.connectionManagerTimer"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "FeignApacheHttpClientConfiguration.connectionManagerTimer"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "FeignApacheHttpClientConfiguration.connectionManagerTimer"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "qtp1060492372-285"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ClassGraph-worker-2318"
build.gradle
设置是这样的
test {
useJUnitPlatform()
maxParallelForks = 1
forkEvery = 10
jvmArgs = [
'-Xmx2g',
'-XX:MaxMetaspaceSize=512m',
'-XX:+UseG1GC',
'-XX:G1HeapRegionSize=8m',
'-XX:InitiatingHeapOccupancyPercent=20',
'-XX:ConcGCThreads=1',
'-XX:ParallelGCThreads=1',
'-XX:MaxGCPauseMillis=300',
'-XX:+HeapDumpOnOutOfMemoryError',
'-XX:HeapDumpPath=build/heapdumps',
'-Xlog:gc*:build/gc.log'
]
systemProperties = [
"feign.client.config.default.connectTimeout" : "5000",
"feign.client.config.default.readTimeout" : "5000",
"feign.httpclient.maxConnections" : "3",
"hikari.maximumPoolSize" : "2"
]
}
有人告诉我如何设置吗?