# Out of memory issue

**URL:** <https://community.gatling.io/t/out-of-memory-issue/1142>\
**Category:** Gatling (Open-Source)\
**Created:** [July 7, 2014, 1:43pm UTC](https://community.gatling.io/t/out-of-memory-issue/1142 "2014-07-07T13:43:00Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Moll](https://avatars.discourse-cdn.com/v4/letter/d/97f17d/32.png) [@Daniel\_Moll](https://community.gatling.io/u/Daniel_Moll)\
**Post date:** [July 7, 2014, 1:43pm UTC](https://community.gatling.io/t/out-of-memory-issue/1142/1 "2014-07-07T13:43:00Z")

</div>

Hi guys,

I am running into out of memory issues with my Gatling script (version 2.0.0-SNAPSHOT) when trying to run a high load endurance test (for 48 hours). After approximately 12 hour I see throughput diminishing and eventually Gatling goes out of memory. Based on a post I found on google groups I use the following JVM arguments:

-Xms4g  
-Xmx7g  
-XX:NewSize=2g  
-XX:+HeapDumpOnOutOfMemoryError  
-XX:+AggressiveOpts  
-XX:+OptimizeStringConcat  
-XX:+UseFastAccessorMethods  
-XX:+UseParNewGC  
-XX:+UseConcMarkSweepGC  
-XX:+CMSParallelRemarkEnabled  
-XX:+CMSClassUnloadingEnabled  
-XX:CMSInitiatingOccupancyFraction=75  
-XX:+UseCMSInitiatingOccupancyOnly  
-XX:SurvivorRatio=8  
-XX:MaxTenuringThreshold=1

Could the out of memory be caused by these JVM settings? Or is it somehow due to the way my script is set up (randomSwitch in during loop)?

My script looks like this:

import io.gatling.core.Predef.\_  
import io.gatling.http.Predef.\_

class Search extends Simulation {

println("Heap: " + (Runtime.getRuntime().maxMemory() / 1024 / 1024))

val httpProtocol = http  
.baseURL(“[http://www.host.com](http://www.host.com)”)  
.acceptHeader("""_/_""")  
.acceptEncodingHeader(""“gzip, deflate”"")  
.acceptLanguageHeader(""“en-us,en;q=0.5"”")  
.userAgentHeader(""“Mozilla/5.0 (Windows NT 5.2; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"”")

val headers\_1 = Map(""“Content-Type”"" → “”“application/json; charset=utf-8"”")

val headers\_8 = Map(  
“”“Content-Type”"" → “”“application/json; charset=utf-8"”",  
“”“X-http-Method-Override”"" → “”“PUT”"")

val headers\_12 = Map(  
“”“Accept-Encoding”"" → “”“gzip,deflate”"",  
“”“Content-Type”"" → “”“application/json; charset=utf-8"”",  
“”“X-HTTP-Method-Override”"" → “”“PUT”"")

val step01 =  
exec(http(“POS\_Settings”)  
.get("""/some/url""")  
.check(regex(""“currencyPrecision”"").exists))

.exec(http(“FlightProductCatalogue”)  
.post("""/some/url""")  
.check(regex(""“destination”"").exists)  
.check(regex("""._“id”:"([^"]+)",._""").saveAs(“resource\_ID”))  
.headers(headers\_1)  
.body(RawFileBody(“FlightProductCatalogue.txt”)))

.exec(http(“Lowestprice\_MiniMultimonth\_Teaser”)  
.get("""/some/url""")  
.check(regex(""“originAirport”"").exists))

.exec(session =\>  
session.set(“currentTimestamp”, System.currentTimeMillis)  
)

.exec(http(“Fare\_Teaser”)  
.get("""/some/url""")  
.check(regex(""“originAirport”"").exists))

val step02 =  
exec(http(“Lowestprice\_Multimonth”)  
.get("""/some/url""")  
.check(regex(""“originAirport”"").exists))

val step03 =

exec(http(“Lowestprice\_OutboundMonth”)  
.get("""/some/url""")  
.check(regex(""“originAirport”"").exists))

.exec(http(“Outbound\_Day”)  
.post("""/some/url""")  
.headers(headers\_1)  
.body(RawFileBody(“Outbound\_Day.txt”))  
.check(regex(""“destination”"").exists))

val step04 =

exec(http(“LowestpriceFlights\_Outbound”)  
.get("""/some/url""")  
.check(regex(""“originAirport”"").exists))

.exec(http(“Outbound\_Connection”)  
.post("""/some/url""")  
.headers(headers\_8)  
.body(RawFileBody(“Outbound\_Connection.txt”))  
.check(regex(""“originAirport”"").exists))

val step05 =

exec(http(“Lowestprice\_InboundMonth”)  
.get("""/some/url""")  
.check(regex(""“originAirport”"").exists))

.exec(http(“Inbound\_Day”)  
.post("""/some/url""")  
.headers(headers\_1)  
.body(RawFileBody(“Inbound\_Day.txt”))  
.check(regex(""“originAirport”"").exists))

val step06 =

exec(http(“LowestpriceFlights\_Inbound”)  
.get("""/some/url""")  
.check(regex(""“originAirport”"").exists))

.exec(http(“Inbound\_Flight”)  
.post("""/some/url""")  
.headers(headers\_12)  
.body(RawFileBody(“Inbound\_Flight.txt”))  
.check(regex(""“originAirport”"").exists))

.exec(http(“Timetothink”)  
.get("""/some/url""")  
.check(status.is(404)))

.exec(http(“Pricedetails”)  
.get("""/some/url""")  
.check(regex(""“amountsPerPassengerType”"").exists))

val scn = scenario(“search”)

.during(172800) {

randomSwitch(

30.0 → exec(step01, step02, step03, step04, step05, step06)

---

<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:** [July 7, 2014, 1:46pm UTC](https://community.gatling.io/t/out-of-memory-issue/1142/2 "2014-07-07T13:46:57Z")

</div>

Hi Daniel.

That’s weird, your simulation is pretty basic.  
Would it be possible for you to share your heap dump, please?

Cheers,

Stéphane

---

<div class="post-metadata">

**Author:** ![Daniel\_Moll](https://avatars.discourse-cdn.com/v4/letter/d/97f17d/32.png) [@Daniel\_Moll](https://community.gatling.io/u/Daniel_Moll)\
**Post date:** [July 7, 2014, 1:50pm UTC](https://community.gatling.io/t/out-of-memory-issue/1142/3 "2014-07-07T13:50:25Z")

</div>

Sure, but the question is how 🙂

---

<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:** [July 7, 2014, 1:53pm UTC](https://community.gatling.io/t/out-of-memory-issue/1142/4 "2014-07-07T13:53:45Z")

</div>

Compress, then Dropbox like, maybe?

---

<div class="post-metadata">

**Author:** ![Daniel\_Moll](https://avatars.discourse-cdn.com/v4/letter/d/97f17d/32.png) [@Daniel\_Moll](https://community.gatling.io/u/Daniel_Moll)\
**Post date:** [July 7, 2014, 1:55pm UTC](https://community.gatling.io/t/out-of-memory-issue/1142/5 "2014-07-07T13:55:46Z")

</div>

Yes I see I have enough room in my dropbox, what email adress should I use to share my dropbox with?

---

<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:** [July 7, 2014, 1:58pm UTC](https://community.gatling.io/t/out-of-memory-issue/1142/6 "2014-07-07T13:58:07Z")

</div>

Mine, please: [slandelle@excilys.com](mailto:slandelle@excilys.com)

---

<div class="post-metadata">

**Author:** ![Floris\_Kraak](https://avatars.discourse-cdn.com/v4/letter/f/848f3c/32.png) [@Floris\_Kraak](https://community.gatling.io/u/Floris_Kraak)\
**Post date:** [July 7, 2014, 2:07pm UTC](https://community.gatling.io/t/out-of-memory-issue/1142/7 "2014-07-07T14:07:50Z")

</div>

Nice work daniel 🙂

---

<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:** [July 7, 2014, 10:50pm UTC](https://community.gatling.io/t/out-of-memory-issue/1142/8 "2014-07-07T22:50:37Z")

</div>

It should be fine now: [https://github.com/excilys/gatling/issues/1997](https://github.com/excilys/gatling/issues/1997)

Things will be even better once I’ve released and integrated AHC 1.9.

Thanks a lot for reporting!

---

<div class="post-metadata">

**Author:** ![Daniel\_Moll](https://avatars.discourse-cdn.com/v4/letter/d/97f17d/32.png) [@Daniel\_Moll](https://community.gatling.io/u/Daniel_Moll)\
**Post date:** [July 8, 2014, 6:37am UTC](https://community.gatling.io/t/out-of-memory-issue/1142/9 "2014-07-08T06:37:28Z")

</div>

You’re welcome! Love to report issues that are fixed the next day 😉

Thanks for your swift action!

I will get back to you soon with feedback on your fix .

cheers

Daniel

---

<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:** [July 8, 2014, 6:38am UTC](https://community.gatling.io/t/out-of-memory-issue/1142/10 "2014-07-08T06:38:10Z")

</div>

Crossing fingers 🙂

---

<div class="post-metadata">

**Author:** ![Daniel\_Moll](https://avatars.discourse-cdn.com/v4/letter/d/97f17d/32.png) [@Daniel\_Moll](https://community.gatling.io/u/Daniel_Moll)\
**Post date:** [July 9, 2014, 7:40am UTC](https://community.gatling.io/t/out-of-memory-issue/1142/11 "2014-07-09T07:40:45Z")

</div>

Hi Stephane,

I did a rerun of the test last night. Gatling is still running out of memory but the good news is it is taking longer now. Unfortunately I did not have the time to wait for the actual out of memory so I don’t have another heap dump for you. Reading issue 1997 made me realize though what might the root cause of the problems. One of the urls in the script is unique on every call because it has a dynamically generated timestamp in it which I set every time the call is made:

.exec(session =\>  
session.set(“currentTimestamp”, System.currentTimeMillis)  
)

If there is no limit to the Gatling cache size this would in the end always result in running out of memory. Could this be the case? I’m currently re-running the test with the caching disabled and I see the script is using 512 Mb max only.

cheers

Daniel

---

<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:** [July 9, 2014, 7:58am UTC](https://community.gatling.io/t/out-of-memory-issue/1142/12 "2014-07-09T07:58:20Z")

</div>

Hi Daniel,

---

<div class="post-metadata">

**Author:** ![Alex\_Bagehot](https://avatars.discourse-cdn.com/v4/letter/a/d78d45/32.png) [@Alex\_Bagehot](https://community.gatling.io/u/Alex_Bagehot)\
**Post date:** [July 9, 2014, 10:55am UTC](https://community.gatling.io/t/out-of-memory-issue/1142/13 "2014-07-09T10:55:44Z")

</div>

FYI although this issue is worked out, you don’t have to wait for the OOM error if the leak is slow to get a useful heap dump.

there are various ways to get a heap dump from a running jvm which you suspect is using too much memory: jmap, gcore/gdb, etc

typically get the diagnostics (thread dumps / heap dump) first, then if not needed they can be deleted after.

Thanks

Alex

---

<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:** [July 9, 2014, 1:30pm UTC](https://community.gatling.io/t/out-of-memory-issue/1142/14 "2014-07-09T13:30:40Z")

</div>

[https://github.com/excilys/gatling/issues/2002](https://github.com/excilys/gatling/issues/2002)

Things should be better now.

---

<div class="post-metadata">

**Author:** ![Floris\_Kraak](https://avatars.discourse-cdn.com/v4/letter/f/848f3c/32.png) [@Floris\_Kraak](https://community.gatling.io/u/Floris_Kraak)\
**Post date:** [July 9, 2014, 8:54pm UTC](https://community.gatling.io/t/out-of-memory-issue/1142/15 "2014-07-09T20:54:35Z")

</div>

@daniel: some jvms will heapdump if you send it a kill -3 signal. Not sure if the sun jvm does, but that works for websphere at least.
