Search code examples
jmeterout-of-memory

Jmeter getting out of memory exception. What should I change the heap size to?


I'm trying to do some load testing with jmeter with about 10000 to 15000 load. when i try to run the script in command-line I'm getting the out of memory exception. I have read that you can increase the JVM memory in the JMeter batch file and modify HEAP size in the JMeter batch file up to 80% of total memory.

So what i'm assuming is there's two files to edit. Can someone confirm me what file should be edited exactly please. I'm running jmeter on a 12GB RAM machine and current have not setup any method for distributed testing. So what is the proper way to allocate more memory to jmeter?


Solution

  • OutOfMemoryError exception has many faces and only one of them is connected with the lack of heap space. If you believe that's your case: you don't need to edit any file in order to change the heap size, it's sufficient to set HEAP environment variable

    Windows:

    set HEAP=-Xms1g -Xmx10g -XX:MaxMetaspaceSize=256m && jmeter.bat
    

    Unix and derivatives:

    export HEAP=-Xms1g -Xmx10g -XX:MaxMetaspaceSize=256m && ./jmeter.sh
    

    If you want to make the change permanent - find the following lines and amend them accordingly:

    the line numbers are provided for JMeter 5.5

    However be informed that larger your heap size - more time it will be required for the garbage collection and most probably JMeter won't be sending any requests during that period.