Load Testing with JMeter – Tips and Tricks

Load Testing with JMeter – Tips and Tricks

Increasing the heap size

By default, JMeter uses 1 GB of heap memory. This may not be enough and you may encounter an Out of Memory exception.

Maximum Heap memory size can be increased to say 2GB by adding the following line in JMeter startup script:

HEAP="-Xms1g -Xmx2g -XX:MaxMetaspaceSize=256m"

Xmx2g means maximum heap size is set to 1 GB. Xmx4g would mean 4GB. While Xms1g specifies the minimum heap size as 1 GB.

This line can be added at the top of the startup script file.

The startup script file would be jmeter.bat on windows and jmeter.sh on Linux.

Suppress the warning about Nashorn scripting engine

You may get the following warning on console with each script execution if you are using a JavaScript engine, for instance, JSR223 sampler.

Warning: Nashorn engine is planned to be removed from a future JDK release

Use the following command to suppress the warning.

On Linux

export JVM_ARGS="-Dnashorn.args=--no-deprecation-warning"

On Windows

SET JVM_ARGS="-Dnashorn.args=--no-deprecation-warning"

Running JMeter in Non-GUI mode

GUI mode is only for setting up and script and verifying it. For actual load testing, it is recommended to run JMeter in non-GUI mode.

jmeter -n –t test.jmx -l testresults.jtl

-n: It specifies JMeter is to run in non-gui mode
-t: Name of JMX file that contains the Test Plan
-l: Name of JTL file to log results

Maintain User Sessions (send back cookies)

Unlike the browser, JMeter will not send cookies back to the server with each request by default. To send cookies set in earlier requests, include HTTP Cookie Manager in the test plan. We just need to include it, no further configuration is required.

Using Selenium with JMeter

JMeter can be integrated with Selenium. This enables us to test single page applications (SPA) and the performance of AJAX calls.

Find more about it here.

While Controller condition

‘While Controller’ condition field only accepts a variable or a function. To specify an expression, we can use the following syntax.

${__javaScript(      ${currentPageNo} > 10    ,)}

Further Reading

One Reply to “Load Testing with JMeter – Tips and Tricks”

Leave a Reply

Your email address will not be published.