# OOM on gatling

**URL:** <https://community.gatling.io/t/oom-on-gatling/466>\
**Category:** Gatling (Open-Source)\
**Created:** [June 26, 2013, 10:53pm UTC](https://community.gatling.io/t/oom-on-gatling/466 "2013-06-26T22:53:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shawna](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@Shawna](https://community.gatling.io/u/Shawna)\
**Post date:** [June 26, 2013, 10:53pm UTC](https://community.gatling.io/t/oom-on-gatling/466/1 "2013-06-26T22:53:05Z")

</div>

I am getting this when running gatling:

Dumping heap to java\_pid8409.hprof …  
Heap dump file created [585273257 bytes in 5.761 secs]  
Uncaught error from thread [GatlingSystem-akka.actor.default-dispatcher-7] shutting down JVM since ‘akka.jvm-exit-on-fatal-error’ is enabled for ActorSystem[GatlingSystem]  
java.lang.OutOfMemoryError: Java heap space  
at java.util.Arrays.copyOfRange(Arrays.java:2694)  
at java.lang.String.(String.java:203)  
at java.nio.HeapCharBuffer.toString(HeapCharBuffer.java:561)  
at java.nio.CharBuffer.toString(CharBuffer.java:1201)  
at org.jboss.netty.buffer.ChannelBuffers.decodeString(ChannelBuffers.java:1207)  
at org.jboss.netty.buffer.AbstractChannelBuffer.toString(AbstractChannelBuffer.java:550)  
at org.jboss.netty.buffer.AbstractChannelBuffer.toString(AbstractChannelBuffer.java:542)  
at com.ning.http.client.providers.netty.NettyResponse.getResponseBody(NettyResponse.java:92)  
at io.gatling.http.response.GatlingResponse.getResponseBody(Response.scala:61)  
at io.gatling.http.check.HttpCheckBuilders$$anonfun$2.apply(HttpCheckBuilders.scala:36)  
at io.gatling.http.check.HttpCheckBuilders$$anonfun$2.apply(HttpCheckBuilders.scala:36)  
at io.gatling.core.check.CheckBase$$anonfun$memoizedPrepared$1$1.apply(Check.scala:53)  
at io.gatling.core.check.CheckBase$$anonfun$memoizedPrepared$1$1.apply(Check.scala:53)  
at scala.collection.mutable.MapLike$class.getOrElseUpdate(MapLike.scala:189)  
at scala.collection.mutable.AbstractMap.getOrElseUpdate(Map.scala:91)  
at io.gatling.core.check.CheckBase.memoizedPrepared$1(Check.scala:53)  
at io.gatling.core.check.CheckBase.check(Check.scala:63)  
at io.gatling.http.check.HttpCheck.check(HttpCheck.scala:30)  
at io.gatling.http.check.HttpCheck.check(HttpCheck.scala:29)  
at io.gatling.core.check.Checks$$anonfun$check$1$$anonfun$apply$1.apply(Check.scala:30)  
at io.gatling.core.check.Checks$$anonfun$check$1$$anonfun$apply$1.apply(Check.scala:30)  
at io.gatling.core.validation.Success.flatMap(Validation.scala:27)  
at io.gatling.core.check.Checks$$anonfun$check$1.apply(Check.scala:30)  
at io.gatling.core.check.Checks$$anonfun$check$1.apply(Check.scala:29)  
at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:111)  
at scala.collection.immutable.List.foldLeft(List.scala:84)  
at io.gatling.core.check.Checks$.check(Check.scala:29)  
at io.gatling.http.ahc.GatlingAsyncHandlerActor.checkAndProceed$1(GatlingAsyncHandlerActor.scala:224)  
at io.gatling.http.ahc.GatlingAsyncHandlerActor.io$gatling$http$ahc$GatlingAsyncHandlerActor$$processResponse(GatlingAsyncHandlerActor.scala:237)  
at io.gatling.http.ahc.GatlingAsyncHandlerActor$$anonfun$receive$1.applyOrElse(GatlingAsyncHandlerActor.scala:103)  
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:425)  
at akka.actor.ActorCell.invoke(ActorCell.scala:386)

---

<div class="post-metadata">

**Author:** ![Shawna](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@Shawna](https://community.gatling.io/u/Shawna)\
**Post date:** [June 27, 2013, 3:35am UTC](https://community.gatling.io/t/oom-on-gatling/466/2 "2013-06-27T03:35:49Z")

</div>

I am getting it quite often now even i am up the xmx to 3072M (used to be 512M).

My scenario is a little bit tricky, since as requested, our testing scenarios are long sessions from the start of the run to the end of the run. So I guess probably that is why the memory can not be released and cause this OOM?

Any help on this?

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [June 27, 2013, 5:09am UTC](https://community.gatling.io/t/oom-on-gatling/466/3 "2013-06-27T05:09:26Z")

</div>

Well, I would need your heap dump.  
Would you happen to do your own stuff with the response bodies, like saving them into the Session (willingly, or unwillingly, like doing a substring or a regex and saving the result)?

---

<div class="post-metadata">

**Author:** ![Nicolas\_R](https://avatars.discourse-cdn.com/v4/letter/n/f14d63/32.png) [@Nicolas\_R](https://community.gatling.io/u/Nicolas_R)\
**Post date:** [June 27, 2013, 5:13am UTC](https://community.gatling.io/t/oom-on-gatling/466/4 "2013-06-27T05:13:42Z")

</div>

Add this option to Java for the heap dump: -XX:+HeapDumpOnOutOfMemoryError

---

<div class="post-metadata">

**Author:** ![Shawna](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@Shawna](https://community.gatling.io/u/Shawna)\
**Post date:** [June 27, 2013, 7:10am UTC](https://community.gatling.io/t/oom-on-gatling/466/5 "2013-06-27T07:10:28Z")

</div>

Yeah, I do need to save some bodyString to parse since the regex does not fit me. Should I use the tranform function instead of saving the body string in sessions and do the parse there? Will that make differences?

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [June 27, 2013, 7:48am UTC](https://community.gatling.io/t/oom-on-gatling/466/6 "2013-06-27T07:48:55Z")

</div>

Yes, you should be using transform so that you only save the bits you’re interested in and the body strings can be garbage collected ASAP.  
If you don’t/can’t do that, at least remove the attributes storing body strings as soon as you’re done parsing them.

---

<div class="post-metadata">

**Author:** ![Shawna](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@Shawna](https://community.gatling.io/u/Shawna)\
**Post date:** [June 27, 2013, 4:35pm UTC](https://community.gatling.io/t/oom-on-gatling/466/7 "2013-06-27T16:35:37Z")

</div>

Ok I will remove those attributes from the sessions after done.

So I am using 2.0.0M.  
`https://github.com/excilys/gatling/wiki/Gatling-2`

`Does session still have the removeAttribute functions? Seems like it goes away for 2.0.0. What's the best way to do that?`

`session.set(attributeName, null)?`

---

<div class="post-metadata">

**Author:** ![Shawna](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@Shawna](https://community.gatling.io/u/Shawna)\
**Post date:** [June 27, 2013, 5:07pm UTC](https://community.gatling.io/t/oom-on-gatling/466/8 "2013-06-27T17:07:56Z")

</div>

BTW, Do you have some good examples on how to use transform function? I looked at wiki one, it is pretty simple. Want to get more help on how to write those

---

<div class="post-metadata">

**Author:** ![Shawna](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@Shawna](https://community.gatling.io/u/Shawna)\
**Post date:** [June 28, 2013, 5:25am UTC](https://community.gatling.io/t/oom-on-gatling/466/9 "2013-06-28T05:25:50Z")

</div>

Never mind, it is more about scala, I can figure it out by myself

Thx for the help!
