sbt plugin: Unable to use overrideDefaultJavaOptions

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:

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?)

Hi Ashis,

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

Cheers,

Pierre

Fixed : https://github.com/gatling/gatling-sbt/commit/2978f8ba55ae46f1af0e4d6f973217b7b8170deb

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

Many thanks Pierre.