2.2 error - out of memory trying to expand an array

Received the following at the end of a test run. May be a valid error, may be because my scenario is totally busted… Either way, wanted to pass it on, just in case.

Uncaught error from thread [GatlingSystem-akka.actor.default-dispatcher-5] shutting down JVM since ‘akka.jvm-exit-on-fatal-error’ is enabled for ActorSystem[GatlingSystem]

java.lang.OutOfMemoryError: Requested array size exceeds VM limit

at java.util.Arrays.copyOf(Unknown Source)

at java.lang.AbstractStringBuilder.expandCapacity(Unknown Source)

at java.lang.AbstractStringBuilder.ensureCapacityInternal(Unknown Source)

at java.lang.AbstractStringBuilder.append(Unknown Source)

at java.lang.StringBuilder.append(Unknown Source)

at scala.collection.mutable.StringBuilder.append(StringBuilder.scala:210)

at scala.collection.immutable.StringLike$class.$times(StringLike.scala:70)

at scala.collection.immutable.StringOps.$times(StringOps.scala:30)

at io.gatling.core.stats.writer.ConsoleSummary$.io$gatling$core$stats$writer$ConsoleSummary$$writeUsersCounters$1(ConsoleSummary.scala:58)

at io.gatling.core.stats.writer.ConsoleSummary$$anonfun$1.apply(ConsoleSummary.scala:87)

at io.gatling.core.stats.writer.ConsoleSummary$$anonfun$1.apply(ConsoleSummary.scala:87)

at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)

at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)

at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:99)

at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:99)

at scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:230)

at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:40)

at scala.collection.mutable.HashMap.foreach(HashMap.scala:99)

at scala.collection.TraversableLike$class.map(TraversableLike.scala:245)

at scala.collection.AbstractTraversable.map(Traversable.scala:104)

at io.gatling.core.stats.writer.ConsoleSummary$.apply(ConsoleSummary.scala:87)

at io.gatling.core.stats.writer.ConsoleDataWriter.onFlush(ConsoleDataWriter.scala:73)

at io.gatling.core.stats.writer.ConsoleDataWriter.onFlush(ConsoleDataWriter.scala:51)

at io.gatling.core.stats.writer.DataWriter$$anonfun$2.applyOrElse(DataWriter.scala:62)

at io.gatling.core.stats.writer.DataWriter$$anonfun$2.applyOrElse(DataWriter.scala:60)

at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36)

at akka.actor.FSM$class.processEvent(FSM.scala:604)

at io.gatling.core.stats.writer.DataWriter.processEvent(DataWriter.scala:30)

at akka.actor.FSM$class.akka$actor$FSM$$processMsg(FSM.scala:598)

at akka.actor.FSM$$anonfun$receive$1.applyOrElse(FSM.scala:570)

at akka.actor.Actor$class.aroundReceive(Actor.scala:467)

at io.gatling.core.akka.BaseActor.aroundReceive(BaseActor.scala:24)

The ConsoleSummary is what is periodically printed in the console.
It uses a Java StringBuilder, which is backed by a char[], which, like all arrays, has a max size of a little bit less than Integer.MAX_VALUE, which is more than 2 billions.
Somehow, you have some many different request names that you end up with a humongous ConsoleSummary and manage to exceed its size.
I’m not sure it’s worth trying to optimize this and try to flush the StringBuilder before it overflow. Such a console output is useless anyway.
IMO, for such use case, you should disable the console output.

Good to know. Thanks!