如何在Spring Boot应用程序中从Gradle测试中收集堆转储



在Spring Boot应用程序中运行集成测试时,我试图诊断内存泄漏。

当我运行时:

./gradlew test -i --XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/Users/ng.newbie/Desktop/heapdump.bin

我不断收到OOM错误:

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "pem.item.service.exchange.allocation-97"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "pem.item.service.exchange.itemAssortment-97"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "pem.item.service.exchange.order-97"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "pem.item.service.exchange.planning-97"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "HikariPool-37 housekeeper"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "HikariPool-1 housekeeper"

但是在指定的目录中没有堆转储。

我还尝试将以下内容添加到我的gradle.properties:

org.gradle.jvmargs=-XX:MaxPermSize=512m -XX:PermSize=128m -Xmx1024m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/Users/ng.newbie/Desktop/crash.hprof

没有变化。

我做错了什么?

如何收集gradle test的堆转储?

build.gradle文件中添加以下内容

test {
jvmArgs '-XX:+HeapDumpOnOutOfMemoryError'
}

最新更新