20

When try to run jMeter with 50 or more user it gives OutOfMemoryError:

2013/12/18 13:35:15 ERROR - jmeter.threads.JMeterThread: Error processing Assertion  java.lang.OutOfMemoryError: Java heap space
2013/12/18 13:35:15 ERROR - jmeter.threads.JMeterThread: Error processing Assertion     java.lang.OutOfMemoryError: Java heap space
2013/12/18 13:35:15 ERROR - jmeter.threads.JMeterThread: Error processing Assertion  java.lang.OutOfMemoryError: Java heap space
2013/12/18 13:35:15 ERROR - jmeter.threads.JMeterThread: Error processing Assertion  java.lang.OutOfMemoryError: Java heap space
2013/12/18 13:35:16 ERROR - jmeter.threads.JMeterThread: Test failed! java.lang.OutOfMemoryError: Java heap space
2013/12/18 13:35:17 ERROR - jmeter.threads.JMeterThread: Test failed! 

I tried to increase the heap size but still getting the same error.
Even i tried to remove all the listeners but nothing changed.

2

8 Answers 8

41

It looks like that you're just lacking Java Heap Space. It's normal as JMeter by default has a very low heap allocation. It's controllable via -Xmx parameter.

There is a line in jmeter.bat or jmeter.sh script which recommends launching JMeter as

JVM_ARGS="-Xms512m -Xmx512m" jmeter.sh

You can try increasing maximum heap until you'll stop receiving these errors. I'd recommend to set it to something like 80% of your hardware RAM.

Also consider JMeter Performance and Tuning Tips article to make sure that you disable memory-consuming listeners, don't overscript, use post-processors efficiently, etc.

10

After the increase, the heap size in bat file remove all listener from the test plan, Then run your script and see the magic.Now you won't get out of memory error in jmeter Enjoy!

1
  • nice pick, Listeners takes lots of memory +1 for that.
    – Chetan
    Jun 25, 2014 at 13:32
3

in the Jmeter 3.x. there are two steps to solve this problem.

Step 1, to modify the JVM memory in the JMeter batch file

##   ==============================================
##   Environment variables:
##   JVM_ARGS - optional java args, e.g. -Dprop=val
##
##   e.g.
##   JVM_ARGS="-Xms512m -Xmx512m" jmeter etc.
##
##   ==============================================

this is a default value in the jmeter.sh, according to your environment:

JVM_ARGS="-Xms512m -Xmx2048m"

in the jmeter.bat:

set JVM_ARGS=-Xms512m -Xmx2048m

Step 2, to Modify HEAP="-Xms512m -Xmx512m" in the JMeter batch file:

in the jmeter.sh

HEAP="-Xms512m -Xmx2048m"

in the jmeter.bat:

set HEAP=-Xms512m -Xmx2048m
2

Open bin/jmeter.bat on windows or bin/jmeter.sh on linux, find this line:

set HEAP=-Xms512m -Xmx512m

This variable is passed as arguments to jmeter at startup. Increase the default heapsize like this:

set HEAP=-Xms1024m -Xmx1024m

You could add more space if you have available and if jmeter needs more. Hope that helps.

1

also you should always consider running your test non-gui mode.

0

There can be many reasons why JMeter is consuming a lot of memory:

  • Use and abuse of UI Listeners,
  • Running a test in UI mode: run the test in batch mode instead
  • JMeter SaveService badly configured: Are you saving requests and responses in JTL?
  • Too many threads per JMeter load generator? Usually less than 1000 per engine should be okay, but it depends on the script complexity too. See Remote Testing to run JMeter in Distributed Mode.

Tweaking the Heap is just one way to fix those issues:

JVM_ARGS="-Xms512m -Xmx512m" jmeter.sh

Check out JMeter Out Of Memory: 12 Ways to Fix Them for even more valuable tips.

0

My one liner for this on a Mac (jmeter is bash script in this case):

$ JVM_ARGS="-Xms4g -Xmx4g -XX:NewSize=4g -XX:MaxNewSize=4g" && export JVM_ARGS && jmeter

0

To set a higher JVM heap space, find your jmeter script (/usr/share/jmeter/bin/jmeter on Ubuntu when jmeter was installed through apt) and add the following line (found on https://www.blazemeter.com/blog/9-easy-solutions-jmeter-load-test-%e2%80%9cout-memory%e2%80%9d-failure/) before the run_java line:

HEAP="-Xms512m -Xmx4g"

Here the maximum heap space was increased to 4GB.

However you might still run out of memory. This can happen when you run a lot of samples and you have a listener which collects data for each sample (for example Listener -> View Results in Tree). Remove this kind of (result) listener and focus on summarized result listeners (e.g. Listener -> Summary Report). This uses much less heap space, even for large stress tests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.