In these days I added a bundle of codes to my project, Gradle build failed in Github actions, some tests throw OOM error when running Gradle test task.
The project tech stack is Spring Boot 3/R2dbc + Kotlin 1.8/Kotlin Coroutines+ Java 17(Gradle Java Language level set to 17)
The build tooling stack.
- Local system: Windows 10 Pro(with 16G memory)/Oracle JDK 17/Gradle 7.6(project Gradle wrapper)
- Github actions: Custom Ubuntu with 16G memory/Amazon JDK 17
After researching, we use a custom larger runner with 16G memory, and increase the Gradle JVM heap size to 8G, but it is no help.
org.gradle.jvmargs=-Xmx8g -Xms4g
We still get the following errors when running tests. But testing codes itself is not a problem, they have been passed on my local machine.
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message can't create name string at src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 827
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ClassGraph-worker-439"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ClassGraph-worker-438"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "boundedElastic-evictor-1"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ClassGraph-worker-435"
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message can't create name string at src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 827
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ClassGraph-worker-433"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ClassGraph-worker-436"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ClassGraph-worker-432"
Update: After posting this question on Spring Boot and other discussion, now confirmed it was caused by classgraph. Classgraph is used by spring doc to scan and analyze the OpenAPI endpoints. If I remove spring doc from the project, it works again.
The problem is even I setup a global springdoc.packageToScan
to shrink the scan scope, it still failed with OOM error.