Memory Issue due to 'java.lang.OutOfMemoryError: Java Heap Space' in Scenario with Extensive Code

We are getting “java.lang.OutOfMemoryError: Java heap space” error while running 20 methods at a time. Below is the error detail.

Exception in thread “main” java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(
at java.base/java.lang.reflect.Constructor.newInstance(
at Engine$.delayedEndpoint$Engine$1(Engine.scala:11)
at Engine$delayedInit$body.apply(Engine.scala:4)
at scala.Function0.apply$mcV$sp(Function0.scala:39)
at scala.Function0.apply$mcV$sp$(Function0.scala:39)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
at scala.App.$anonfun$main$1$adapted(App.scala:80)
at scala.collection.immutable.List.foreach(List.scala:392)
at scala.App.main(App.scala:80)
at scala.App.main$(App.scala:78)
at Engine$.main(Engine.scala:4)
at Engine.main(Engine.scala)
Caused by: java.lang.OutOfMemoryError: Java heap space

Any Suggestion?

Please suggest how to manage scenarios where more than 20000 line of codes are being generated?

Additionally, what are the memory and line of code thresholds in Gatling?

Thanks in Advance!!

Loading the simulation itself is unlikely to cause an excessive heap usage.
Either your heap is ridiculously small, or you’re loading a humongous amount of data in memory.

In any case, there’s no way to help you unless you follow the requirements for asking a question: How to Ask a Question.

Hi Stéphane,

While generating a Scala file from a Har file, we encountered an extensive codebase of more than 17,000 lines. We noticed that memory issues arise when the code exceeds 1,000 lines. To address this, we partitioned the code into different Scala files, resulting in 20 separate files, which are then invoked from a central Scala file.
However, despite attempting to increase the maximum heap size from 991 to 6144.
The issue still persists


This OOME doesn’t happen at compile time. It’s not related to the amount of code.
Get a heap dump and analyze it.

impossible to help you without you providing a reproducer as requested.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.