Reputation: 231
I am facing below OutOfMemor errors, and JMeter stops working....
java.lang.OutOfMemoryError: Java heap space Dumping heap to
java_pid4412.hprof ... Heap dump file created [591747609 bytes in
71.244 secs] Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space Exception in thread
"AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError:
Java heap space Exception in thread "AWT-EventQueue-0"
java.lang.OutOfMemoryError: Java heap space
How can it be resolved?
My System is having very good specification like 16GB RAM, 2x Quad Core processors, with 146 GB HDD.
Can anyone help me?
Upvotes: 23
Views: 119474
Reputation: 1032
This is what worked for me on the latest jmeter.
The suggestion from jmeter is to use the GUI for setting up the tests and the command line for running actual tests. I could run jmeter from the command line using
C:\Users\myUser\Downloads\apache-jmeter-5.6.3\apache-jmeter-5.6.3\bin> jmeter -n -t MyTest.jmx -l results.jtl -e -o log.txt
To increase the max memory, open your JMeter startup script (usually jmeter.sh or jmeter.bat). Look for the line that sets the heap memory (HEAP) and modify it to increase the -Xmx value (maximum heap size).
For example, change the default of
set HEAP=-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m
to
set HEAP="-Xms1g -Xmx4g -XX:MaxMetaspaceSize=256m"
This sets the maximum heap size to 4GB. Adjust it according to your needs.
To verify the change you can check the Max memory in jmeter.log
file in the same path as the executable script.
For example,
<Date> 14:35:09,978 INFO o.a.j.JMeter: Max memory =1073741824
will change to
<Date> 14:46:27,310 INFO o.a.j.JMeter: Max memory =2147483648
Upvotes: 0
Reputation: 5030
A lot of these answers are out-of-date. Currently using jmeter v5.1.1 r1855137:
# Set var to increase available memory
JVM_ARGS="-Xms2048m -Xmx4096m"
# Run jmeter via sh script, e.g.:
/jmeter/5.1.1/libexec/bin/jmeter.sh -n -t testfile.jmx -l results.jtl -j log.txt
You can verify that the increase in memory is available via the log.txt file, which will show the following using the values above:
INFO o.a.j.JMeter: Max memory =3817865216
Upvotes: 9
Reputation: 188
Run Jmeter in non-GUI mode. Increase the heap size of the memory. Add very less/no listeners. For running Jmeter in non-GUI mode, go to bin directory and open command prompt in that window. use the following command "jmeter.bat -n -t Test.jmx -l Test.csv" here Test.jmx is the test file I need to open in non-GUI mode and Test.csv is the file in which I need my results stored. For increasing size of the memory use the command HEAP="-Xms512m -Xmx2048m" here 512 is the already allocated memory and 2048 is the memory I need to allot to Jmeter.
Hope this helps
Upvotes: 2
Reputation:
You should check whether you're not using a tree result listener during your tests with many users.
Check jmeter best practices to avoid this kind of issues.
Regards
Upvotes: 4
Reputation: 3210
In Jmeter version 3.x it is mentioned in $JMETER_HOME/bin/jemter.sh(jmeter.bat):
## Environment variables:
## JVM_ARGS - optional java args, e.g. -Dprop=val
## e.g.
## JVM_ARGS="-Xms512m -Xmx512m" jmeter.sh etc.
so in your case you can set it as much as sufficient to your needs for example:
JVM_ARGS="-Xms1024m -Xmx1024m"
Upvotes: 2
Reputation: 336
You have to change HEAP SIZE in jmeter.bat file. First you have to convert 2GB or 6GB (OR the size which you want to put) size into mb and then save it and relaunch .bat file.
Set value for "set HEAP=-Xms512m -Xmx512m"
Upvotes: 2
Reputation: 2547
To optimize OutOfMemoryError
these steps should be followed:
JMeter is a Java tool it runs with JVM. To obtain maximum capability, we need to provide maximum resources to JMeter during execution.First, we need to increase heap size (Inside JMeter bin directory, we get jmeter.bat/sh
).
HEAP=-Xms512m –Xmx512m
It means default allocated heap size is minimum 512MB, maximum 512MB. Configure it as per you own machine configuration. It should also be kept in mind that OS also need some amount of memory, so all of the physical RAM shouldn't be allocated.
JMeter is Java GUI application. It also has the non-GUI edition which is very resource intensive(CPU/RAM). If we run Jmeter in non-GUI mode , it will consume less resource and we can run more thread.
Listeners should be disabled during load tests. Enabling them causes additional overheads, which consume valuable resources that are needed by more important elements of your test.
Java and JMeter should be kept updated.
When it comes to storing requests and response headers, assertion results and response data can consume a lot of memory! So it is wise try not to store these values on JMeter unless it’s absolutely necessary.
The following JVM arguments in JMeter startup scripts can also be added or modified:
1. Add memory allocation rate:
NEW=-XX:NewSize=128m -XX:MaxNewSize=512m
This means memory will be increased at this rate.
2.-server
- this switches JVM into “server” mode with runtime parameters optimization. In this mode, JMeter starts more slowly, but the overall throughput will be higher.
3. -d64
- While using a 64-bit OS, using this parameter can explicitly tell JVM to run in 64-bit mode.
4. -XX:+UseConcMarkSweepGC
- this forces the usage of the CMS garbage collector. It will lower the overall throughput but leads to much shorter CPU intensive garbage collections.
5. -XX:+DisableExplicitGC
- this prevents applications from forcing expensive garbage collections and helps avoid unexpected pauses.
For better and more elaborated understanding, this blog about 9 Easy Solutions for a JMeter Load Test “Out of Memory” Failure is helpful.
Upvotes: 15
Reputation: 181
Adjust the heap size as mentioned in the other answers and also take some best practices into account
These 2 items will already greatly increase your performance and heap size usage
Upvotes: 0
Reputation: 389
Your Heap dump shows that you are using default JMeter settings of 512 Mo. so even if you have 16gb you are not using them.
Replace default JVM optional in jmeter.bat to the right size:
set HEAP=-server -Xms768m -Xmx768m -Xss128k
set NEW=-XX:NewSize=1024m -XX:MaxNewSize=1024m
Also look at:
Upvotes: 19
Reputation: 869
Though your server has 16 GB RAM, JMeter's default heap size 512 MB, Increase heap size by following below steps
1. Open jmeter file using vi editor /text editor
2. Search for "HEAP"
3. Change minimum (-Xms) and Maximum (-Xmx) heap values as you required
4. Save and quit (!wq enter)
5. Start Jmeter by sh jmeter.sh or bash jmeter.bat or java -jar ApacheJMeter.jar
Upvotes: 2
Reputation: 133
I also had this problem and it did not matter how much I adjusted the configuration java -Xms<initial heap size> -Xmx<maximum heap size>
, as I always ran out of memory. In the end I found out that running JMeter in GUI mode (especially with listeners) causes a bottleneck. The best way to use JMeter, especially for extended testing or running multiple slave servers, is in non-GUI mode, which looks something like this:
jmeter -n -t testplan.jmx -r
Check out this link and read how to do remote testing the proper way: http://wiki.apache.org/jmeter/JMeterFAQ#How_to_do_remote_testing_the_.27proper_way.27.3F. Read the section on remote testing the 'proper way'.
Hope this helps.
Upvotes: 5
Reputation: 8446
How much memory have you allocated for the JVM? Somewhere aroung 512 MB?
The configuration is
java -Xms<initial heap size> -Xmx<maximum heap size>
Upvotes: 17