Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMeter OutOfMemoryError

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?

like image 627
james Avatar asked Feb 18 '10 06:02

james


People also ask

How do you fix OutOfMemoryError?

1) An easy way to solve OutOfMemoryError in java is to increase the maximum heap size by using JVM options "-Xmx512M", this will immediately solve your OutOfMemoryError.

How much memory does JMeter need?

RAM: At least 16Gb RAM, 32GB recommended. Avoid using more than 50% RAM.


4 Answers

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:

  • http://wiki.apache.org/jmeter/JMeterFAQ#JMeter_keeps_getting_.22Out_of_Memory.22_errors.__What_can_I_do.3F

  • http://www.ubik-ingenierie.com/blog/jmeter_performance_tuning_tips/

like image 145
ChamaraS Avatar answered Oct 12 '22 22:10

ChamaraS


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> 
like image 36
Aleksi Yrttiaho Avatar answered Oct 12 '22 22:10

Aleksi Yrttiaho


To optimize OutOfMemoryError these steps should be followed:

  • Increase the Java Heap Size:

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.

  • Run Tests in Non-GUI Mode:

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.

  • Disable ALL Listeners during the Test Run. They are only for debugging and use them to design the desired script.

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.

  • Use Up-to-Date Software:

Java and JMeter should be kept updated.

  • Decide Which Metrics You Need to Store:

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.

  • Tweak JVM:

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.

like image 22
Adnan Avatar answered Oct 12 '22 21:10

Adnan


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
like image 44
greg7gkb Avatar answered Oct 12 '22 20:10

greg7gkb