如何从 Spring 引导应用程序中的 Gradle 测试收集堆转储?
How can I collect a heap dump from Gradle tests in a Spring Boot Application?
我在 运行 我的 Spring 启动应用程序中进行集成测试时试图诊断内存泄漏。
当我 运行 :
./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'
}
我在 运行 我的 Spring 启动应用程序中进行集成测试时试图诊断内存泄漏。
当我 运行 :
./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'
}