HOME BLOG

Archive for the ‘Java’ Category

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/

How to disable a test class or method in Java

Posted on: April 26th, 2024 by Olu No Comments

Hi folks,

In this brief post, we will talk about how to disable a test class or method in a Java-based project. Why would you want to do this? It could be because the test isn’t yet fully implemented. Another situation is if you have Continuous Integration in place where tests are run automatically during a build, but a certain test class isn’t yet ready for automatic execution.

To disable a test class or method, you can use the Disabled annotation from JUnit. E.g.

import org.junit.jupiter.api.Disabled
...

@Disabled
class YourTestClass {
...
}

That’s it. Now such a test would be ignored. That’s all for now. Till next time, happy software development.

 

References

Disabled (JUnit 5.0.0-M2 API). https://junit.org/junit5/docs/5.0.0-M2/api/org/junit/jupiter/api/Disabled.html