HOME BLOG

How to set the JVM heap size when running large-scale performance tests with Gatling framework

Posted on: November 13th, 2026 by Olu No Comments

Hi Folks,

In this post, I will cover how to set the JVM heap size size to allow you run large-scale performance tests using the popular Gatling framework.

What do I mean by large-scale? I mean tests that use a lot of memory, for example, endurance tests that simulate very many users using your application over an extended period of time.

When you try implementing these kinds of tests, you may run into out-of-memory heap size error. Why does this happen? It happens because the default heap size may not be sufficient to hold all the user objects needed for the test.

So How do you increase the heap size available to the test? You can do this by specifying a suitable heap size using the -Xmx option. -Xmx specifies the maximum memory allocation pool for a Java Virtual Machine (JVM). How do you pass in -Xmx option? By using the gatling.jvmArgs argument. Assuming you use Maven and you have the Gatling Maven Plugin installed in your project, you can find out about this argument by running the following command:

mvn gatling:help -Ddetail=true -Dgoal=test

So, when you want to run your test, let’s say you want to set the maximum heap size to 2 GB, you can use a command like:

mvn gatling:test gatling.jvmArgs=-Xmx2g

That’s all for now. Till next time, happy software development.

Resources

OndraZizka/GatlingMavenPluginDocs.md. https://gist.github.com/OndraZizka/7deaef4ec68a1769f9b4ffc67a487bda

Gatling Maven Plugin. https://docs.gatling.io/integrations/build-tools/maven-plugin/

Gatling. https://gatling.io/

Leave a Reply