Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jmeter, how to increase heap size

Tags:

java

jmeter

I had read that you need to change the heap size in the jmeter.bat file (I'm using windows) to increase the memory to be able to test around 500 threads or more. This is the default:

if not defined HEAP (
    rem See the unix startup file for the rationale of the following parameters,
    rem including some tuning recommendations
    set HEAP=-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m
)

I changed the set HEAP=-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m it to:

set HEAP=-Xms2g -Xmx8g -XX:MaxMetaspaceSize=512m

But when I open Jmeter in GUI mode there is a message in the command line window

Modify current env variable HEAP="-Xms1g -Xmx1g -XX:MaxMetaSpaceSize=256m" in the jmeter batch file

So does that mean the change in the batch file didn't work? Or it does work when running in non-gui mode? Did I miss something to change or what? Thanks in advance.

like image 492
Jeffrey Aquino Avatar asked Nov 15 '25 20:11

Jeffrey Aquino


1 Answers

  1. You don't need to increase the heap unless you face java.lang.OutOfMemoryError: Java heap space error or detect unusually high GC activity
  2. The message basically a form of advice, you will see it even if you have several terabytes of heap space as it is simply hard-coded and will always be shown during GUI startup. If you want to see all Java arguments including heap space settings you can use JSR223 Sampler and the following Groovy code:

    java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments().each {
        log.info("Effective JVM argument: " + "$it")
    }
    

    This way you can test whether you changes are applied or not:

    enter image description here

like image 157
Dmitri T Avatar answered Nov 17 '25 10:11

Dmitri T