JMeter OutOfMemoryError

2019-03-18 05:00发布

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?

10条回答
smile是对你的礼貌
2楼-- · 2019-03-18 05:16

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.

查看更多
Summer. ? 凉城
3楼-- · 2019-03-18 05:26

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

查看更多
混吃等死
4楼-- · 2019-03-18 05:27

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"
查看更多
该账号已被封号
5楼-- · 2019-03-18 05:27

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

查看更多
成全新的幸福
6楼-- · 2019-03-18 05:28

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.

查看更多
孤傲高冷的网名
7楼-- · 2019-03-18 05:31

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>
查看更多
登录 后发表回答