sbt plugin: Unable to use overrideDefaultJavaOptions

347 views
Skip to first unread message

Ashis Joshi

unread,
Jun 10, 2015, 3:51:40 PM6/10/15
to gat...@googlegroups.com
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(TM) 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(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 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?)

Pierre DAL-PRA

unread,
Jun 14, 2015, 7:32:30 PM6/14/15
to gat...@googlegroups.com
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


--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pierre DAL-PRA

unread,
Jun 14, 2015, 7:38:09 PM6/14/15
to gat...@googlegroups.com

Ashis Joshi

unread,
Jun 16, 2015, 1:23:47 PM6/16/15
to gat...@googlegroups.com
That's great! and no need to apologise for the delay - we are all busy ;-)

Many thanks Pierre.
Reply all
Reply to author
Forward
0 new messages