1

Getting below error message during our load test in jmeter version 5.1.1.

2020-01-17 01:30:00,644 ERROR o.a.j.JMeter: Uncaught exception: 
java.lang.OutOfMemoryError: Java heap space

How much Max memory should we increase in jmeter batch file using command:

HEAP=-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m
1

BlazeMeter article recommends:

Just increase the maximum heap size to ~80% of your total available physical RAM.

HEAP="-Xms512m -Xmx512m"

Now change the -Xmx value accordingly. For example: if you want to set the maximum heap > size to 4 gigabytes, you’ll need to change the line to: HEAP="-Xms512m -Xmx4096m"

1

As per Optimal Heap Size chapter:

"If the occupancy of the Java heap is too high, garbage collection occurs frequently. If the occupancy is low, garbage collection is infrequent but lasts longer... Try to keep the memory occupancy of the Java heap between 40% and 70% of the Java heap size... The highest point of occupancy of the Java heap is preferably not above 70% of the maximum heap size, and the average occupancy is between 40% and 70% occupancy. If the occupancy goes over 70%, resize the Java heap."

"A correctly sized Java heap should always have a memory occupancy of between 40% and 70% of the maximum Java heap size. To ensure that the occupancy does not exceed 70%, set the maximum Java heap size to at least 43% larger than the Maximum occupancy value provided by GCMV. This setting then makes the Maximum value 70% of the Java heap and the average to be above 40% of the Java heap size."

enter image description here

So make sure that:

  1. JMeter has enough headroom to operate
  2. Garbage Collection doesn't happen too often

Use JVisualVM or JMeter PerfMon Plugin to monitor the heap usage by JMeter and tune minimum/maximum according to the above 40% - 70% rule

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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