A very general question: What can be the root caus...
# kotest
s
A very general question: What can be the root cause of running out of heap space when running test using Kotest? We are facing an issue where tests are flaky. This is the console output for failing scenario:
Copy code
org.junit.platform.commons.JUnitException: TestEngine with ID 'kotest' failed to execute tests
org.junit.platform.commons.JUnitException: TestEngine with ID 'kotest' failed to execute tests
Caused by: io.kotest.engine.config.ConfigurationException: io.github.classgraph.ClassGraphException: Uncaught exception during scan
at app//io.kotest.engine.config.ConfigManager$compile$2.invoke(ConfigManager.kt:29)
at app//io.kotest.engine.config.ConfigManager$compile$2.invoke(ConfigManager.kt:29)
at app//io.kotest.common.ResultsKt.mapError(results.kt:8)
at app//io.kotest.engine.config.ConfigManager.compile-gIAlu-s(ConfigManager.kt:29)
at app//io.kotest.engine.config.ConfigManager.initialize(ConfigManager.kt:19)
at app//io.kotest.engine.TestEngineLauncher.toConfig(TestEngineLauncher.kt:196)
at app//io.kotest.engine.TestEngineLauncher$launch$2.invokeSuspend(TestEngineLauncher.kt:222)
at app//io.kotest.engine.TestEngineLauncher$launch$2.invoke(TestEngineLauncher.kt)
at app//io.kotest.engine.TestEngineLauncher$launch$2.invoke(TestEngineLauncher.kt)
at app//io.kotest.common.RunBlockingKt$runBlocking$1.invokeSuspend(runBlocking.kt:3)
at app//kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at app//kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
at app//kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:280)
at app//kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
at app//kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
at app//kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
at app//kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
at app//kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
at app//io.kotest.common.RunBlockingKt.runBlocking(runBlocking.kt:3)
at app//io.kotest.engine.TestEngineLauncher.launch(TestEngineLauncher.kt:221)
at app//io.kotest.runner.junit.platform.KotestJunitPlatformTestEngine.execute(KotestJunitPlatformTestEngine.kt:78)
at app//io.kotest.runner.junit.platform.KotestJunitPlatformTestEngine.execute(KotestJunitPlatformTestEngine.kt:50)
Caused by: io.github.classgraph.ClassGraphException: Uncaught exception during scan
at app//io.github.classgraph.ClassGraph.scan(ClassGraph.java:1610)
at app//io.github.classgraph.ClassGraph.scan(ClassGraph.java:1627)
at app//io.github.classgraph.ClassGraph.scan(ClassGraph.java:1640)
at app//io.kotest.engine.config.ApplyConfigFromAutoScanKt.applyConfigFromAutoScan(applyConfigFromAutoScan.kt:22)
at app//io.kotest.engine.config.ConfigManager.compile-gIAlu-s(ConfigManager.kt:27)
... 18 more
Caused by: java.lang.OutOfMemoryError: Java heap space
at nonapi.io.github.classgraph.fastzipfilereader.NestedJarHandler$8.<init>(NestedJarHandler.java:660)
at nonapi.io.github.classgraph.fastzipfilereader.NestedJarHandler.openInflaterInputStream(NestedJarHandler.java:655)
at nonapi.io.github.classgraph.fileslice.Slice.open(Slice.java:246)
at io.github.classgraph.ClasspathElementZip$1.open(ClasspathElementZip.java:390)
at io.github.classgraph.ClasspathElementZip$1.openClassfile(ClasspathElementZip.java:376)
at io.github.classgraph.Classfile.<init>(Classfile.java:2002)
at io.github.classgraph.Scanner$ClassfileScannerWorkUnitProcessor.processWorkUnit(Scanner.java:725)
at io.github.classgraph.Scanner$ClassfileScannerWorkUnitProcessor.processWorkUnit(Scanner.java:647)
at nonapi.io.github.classgraph.concurrency.WorkQueue.runWorkLoop(WorkQueue.java:246)
at nonapi.io.github.classgraph.concurrency.WorkQueue.access$000(WorkQueue.java:50)
at nonapi.io.github.classgraph.concurrency.WorkQueue$1.call(WorkQueue.java:201)
at nonapi.io.github.classgraph.concurrency.WorkQueue$1.call(WorkQueue.java:198)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
w
Most of the time, that's just going to be caused by putting more on the heap than you have space for. Looking at your stack trace, that seams reasonable, it looks to me as if you're reading files and building a model of them in memory. If you want to truly see what's going on, set up your test to dump a heap image investigate where your heap is getting bigger than you expect. If everything is working as it should and you just need more heap space, make sure your test JVM is launched with an appropriate heap size using
-Xmx...
.
👍 1
199 Views