# sbt plugin: Unable to use overrideDefaultJavaOptions

**URL:** https://community.gatling.io/t/sbt-plugin-unable-to-use-overridedefaultjavaoptions/2353
**Category:** Gatling (Open-Source)
**Created:** [June 10, 2015, 7:51pm UTC](https://community.gatling.io/t/sbt-plugin-unable-to-use-overridedefaultjavaoptions/2353 "2015-06-10T19:51:40Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Ashis\_Joshi](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@Ashis\_Joshi](https://community.gatling.io/u/Ashis_Joshi)
#### Post date: [June 10, 2015, 7:51pm UTC](https://community.gatling.io/t/sbt-plugin-unable-to-use-overridedefaultjavaoptions/2353/1 "2015-06-10T19:51:40Z")

</div>

Hi all,

Thanks for all the work on the sbt plugin. I’m trying to override my sbt config to use a custom Xmx memory setting. The documented way of using:

javaOptions in Gatling := overrideDefaultJavaOptions(“-Xmx2G” )

does not work for me and my JVM just ends up using the value from `DefaultJvmArgs` (-Xmx512m). My workaround is to place the arguments at the end of `javaOptions` instead with:

javaOptions in Gatling ++= Seq(“-Xmx2G”)

I think this happens because `overrideDefaultJavaOptions` places custom JVM arguments at the beginning of the list:

> <https://github.com/gatling/gatling-sbt-plugin/blob/v2.1.6/src/main/scala/io/gatling/sbt/GatlingKeys.scala#L39>

Whereas my JVM uses the last value present. Perhaps parameter order of precedence is different from one JVM implementation to another?

More details below. Thanks very much.

- Ashis

_Environment_  
Gatling 2.1.6 / sbt 0.13.8 / scala 2.11.6 / Mac OSX 10.9.5 (Yosemite) / Oracle Java™ SE Runtime Environment 1.7.0\_79-b15

_Working Out_

Using this line in my build.sbt:  
javaOptions in Gatling := overrideDefaultJavaOptions(“-Xmx2G” )

Results in the following sbt `javaOptions` sequence, i.e. the override setting is at the head of the list followed by the Gatling defaults:

> show javaOptions

[info] ArrayBuffer(-Xmx2G, -server, -XX:+UseThreadPriorities, -XX:ThreadPriorityPolicy=42, -Xms512M, -Xmx512M, -Xmn100M, -XX:+HeapDumpOnOutOfMemoryError, -XX:+AggressiveOpts, -XX:+OptimizeStringConcat, -XX:+UseFastAccessorMethods, -XX:+UseParNewGC, -XX:+UseConcMarkSweepGC, -XX:+CMSParallelRemarkEnabled)

When running the Gatling simulation, `jconsole` tells me that the JVM arguments were:

`-Xmx2G -Dhttp.nonProxyHosts=local|*.local|169.254/16|*.169.254/16 -DsocksNonProxyHosts=local|*.local|169.254/16|*.169.254/16 -Dftp.nonProxyHosts=local|*.local|169.254/16|*.169.254/16 -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms512M -Xmx512M -Xmn100M -XX:+HeapDumpOnOutOfMemoryError -XX:+AggressiveOpts -XX:+OptimizeStringConcat -X:+UseFastAccessorMethods -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled`

i.e. the order from `javaOptions` was retained.

My JVM appears to use the right-most value specified:

> java -Xms256m -Xmx512m -Xmx2048m -XX:+PrintFlagsFinal -version | grep MaxHeapSize

uintx MaxHeapSize := 2147483648 {product}  
java version “1.7.0\_79”  
Java™ SE Runtime Environment (build 1.7.0\_79-b15)  
Java HotSpot™ 64-Bit Server VM (build 24.79-b02, mixed mode)

So should overrides be placed at the end of the list instead? (or possibly at the start and the end of the list? or possibly replace existing values in the list?)

---

<div class="post-metadata">

### Author: ![Pierre\_DAL-PRA](https://avatars.discourse-cdn.com/v4/letter/p/ecccb3/32.png) [@Pierre\_DAL-PRA](https://community.gatling.io/u/Pierre_DAL-PRA)
#### Post date: [June 14, 2015, 11:32pm UTC](https://community.gatling.io/t/sbt-plugin-unable-to-use-overridedefaultjavaoptions/2353/2 "2015-06-14T23:32:26Z")

</div>

Hi Ashis,

First, sorry for the delay 🙂  
Indeed, it seems that, at least on HotSpot, that overrides must be appended and not prepended to work.  
Will fix ASAP.

Cheers,

Pierre

---

<div class="post-metadata">

### Author: ![Pierre\_DAL-PRA](https://avatars.discourse-cdn.com/v4/letter/p/ecccb3/32.png) [@Pierre\_DAL-PRA](https://community.gatling.io/u/Pierre_DAL-PRA)
#### Post date: [June 14, 2015, 11:38pm UTC](https://community.gatling.io/t/sbt-plugin-unable-to-use-overridedefaultjavaoptions/2353/3 "2015-06-14T23:38:07Z")

</div>

Fixed : [https://github.com/gatling/gatling-sbt/commit/2978f8ba55ae46f1af0e4d6f973217b7b8170deb](https://github.com/gatling/gatling-sbt/commit/2978f8ba55ae46f1af0e4d6f973217b7b8170deb)

---

<div class="post-metadata">

### Author: ![Ashis\_Joshi](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@Ashis\_Joshi](https://community.gatling.io/u/Ashis_Joshi)
#### Post date: [June 16, 2015, 5:23pm UTC](https://community.gatling.io/t/sbt-plugin-unable-to-use-overridedefaultjavaoptions/2353/4 "2015-06-16T17:23:47Z")

</div>

That’s great! and no need to apologise for the delay - we are all busy 😉

Many thanks Pierre.
