JVM args issue with gatling maven plugin

755 views
Skip to first unread message

Sandeep Malik

unread,
May 1, 2014, 2:47:43 PM5/1/14
to gat...@googlegroups.com
Hi All,

I was trying to put some custom jvm arguments e.g.
<plugin>
                    <groupId>io.gatling</groupId>
                    <artifactId>gatling-maven-plugin</artifactId>
                    <version>2.0.0-M3a</version>
                    <executions>
                        <execution>
                            <phase>test</phase>
                            <goals>
                                <goal>execute</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        ...
                        <simulationClass>itemstore.simulations.StandaloneProductSimulation</simulationClass>
                        <jvmArgs>
                            <jvmArg>-Xms1024m</jvmArg>
                            <jvmArg>-Xmx4096m</jvmArg>
                        </jvmArgs>
                    ...

but looks like no matter what memory sizes I give here, the simulation code always runs with 512M of min and max memory.
After digging a little deeper (I am using 2.0.0-M3a version of plugin), I found that 512M is default min and max values for heap size. 

I looked at the GatlingMojo.java class and the method which builds jvm args is this:
private List<String> jvmArgs() {
List<String> jvmArguments = (jvmArgs != null) ? jvmArgs : new ArrayList<String>();
jvmArguments.addAll(Arrays.asList(JVM_ARGS));
return jvmArguments;
}

Now, since we're adding default properties in an array list to the existing jvmArgs, the -Xms and _Xmx will be added twice. The final list would look something like "... -Xms1024M ... -Xms512M ..."

In this scenario, looks like JVM is picking up the rightmost arg value and hence ignoring my custom options. 
Is this a bug? 
May be the code should have been:

private List<String> jvmArgs() {
List<String> jvmArguments = (jvmArgs != null) ? jvmArgs : new ArrayList<String>();
Arrays.asList(JVM_ARGS).addAll(jvmArguments) // reverse order:
return jvmArguments;
}

Or may be we could have used a Set (in the same order, custom first, defaults later) to make sure that properties are not overridden by default.

Thanks,
Sandeep

Stéphane Landelle

unread,
May 1, 2014, 3:17:29 PM5/1/14
to gat...@googlegroups.com
Hi,


FYI, how JVM are picked is not specified, you cannot rely on this.

Cheers,

Stéphane


--
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.

Sandeep Malik

unread,
May 1, 2014, 6:17:03 PM5/1/14
to gat...@googlegroups.com
Thanks Stephane! Appreciate quick help, and you're right about JVM agrs order.

Thanks,
Sandeep

Stéphane Landelle

unread,
May 2, 2014, 2:38:54 AM5/2/14
to gat...@googlegroups.com
You're welcome!

If you plan on using the plugin snapshot, beware, it's only compatible with Gatling modules snapshots.
Reply all
Reply to author
Forward
0 new messages