My Account

out of memory error in jmeter

+3 votes
3,576 views
asked in QA Automation Testing by tester (1,550 points)
When I am running my J meter script getting this error :

 

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

When I am running script for 100 users then its happening although script is working for 2,3 users.

Please help!

1 Answer

+1 vote
answered by Himanshu Expert (6,240 points)

This error comes when your java heap space is fully occupied so now you have to increase the heap allocation for JMeter.

Its very easy , You just have to follow these 2 steps :

1. There is a file in JMeter folder called jmeter.bat or jmeter.sh which is used to run jmeter, now you have to just use a parameter while launching jmeter . also you can change this parameter by editing this file.

JVM_ARGS="-Xms512m -Xmx512m" jmeter.sh

You can change this parameter as per your RAM, here it is 512m of your ram. you should use only 80% of your ram capacity.

2. The other thing to reduce this error is your script listeners they consume a good amount of memory so remove all listeners.

 

Now try with more users you won't get this error.

commented by anonymous
Hi Himansu, plz tell me.. where I have to add this .."JVM_ARGS="-Xms512m -Xmx512m" " for windows . For 500 threads Iam getting this "out of memory" error. My System Ram size is 2GB.
commented by Himanshu Expert (6,240 points)
First of all 2 GB Ram is not recommended for 500 threads.

For windows : Path is :  
apache-jmeter-3.0/bin/

Here you will get jmeter.bat file , edit it in notepad as per your need and save it.

There are many ways to optimize JMeter for better performance. It is a complete topic in itself but for starter, I will recommend at least configuring java xms and xmx values in JMeter.bat file. By doing so, you can make sure that JMeter is properly using the available memory resources. It also reduces the chances of OutOfMemory errors.

To change these settings, open jmeter.bat file in notepad and update following lines

1
2
3
4
// default configuration
 
set HEAP=-Xms512m -Xmx512m
set NEW=-XX:NewSize=128m -XX:MaxNewSize=128m
1
2
3

// new settings could be like this *depending* on your hardware and software specs
// note that, Max heap size should not exceed the 80% of total system memory
 
set HEAP=-Xms512m -Xmx2048m
set NEW=-XX:NewSize=128m -XX:MaxNewSize=1024m

Other than this configuration, it is also important to use listeners intelligently in your test plan. Listeners that consume more memory like Table, Tree, Assertion and Graph listeners should be avoided during actual load test execution. It is best to only generate JTL test results file during actual load tests and later that JTL file can be used to create different reports.

Related Questions

0 votes
0 answers 137 views
+2 votes
0 answers 458 views