JMeter pressure measurement Times "out of memory" failure of nine simple solution

Test failed! java.lang.OutOfMemoryError: Java heap space 

Test failed! java.lang.OutOfMemoryError: Java heap space

 

JMeter - out of memory failure

 

Getting JMeter test without changing the current hardware settings of the maximum load

 

1. Increase the Java heap size

Java heap space (referenced in the error message) JVM is obtained from the underlying operating system memory,

Used to create the necessary space for object allocation. 

JMeter default configuration (see jmeter.bat for Windows or non-Windows systems applicable to jmeter script) assumed heap space is only 512 MB.

This is actually quite low!

If your test run of more than 512Mb of large objects,

You will receive an OOM error,

And your test will fail.

The maximum heap size to only about 80% of the total available physical RAM.

to this end,

Please find the following line in the startup script JMeter:

HEAP =“ - Xms512m -Xmx512m”

Now -Xmx value changes accordingly.

E.g:

If you want the maximum heap size to 4 gigabytes,

We need to change the line to: HEAP = "- Xms512m -Xmx4096m"

To apply the changes,

You need to restart JMeter.

 

2. Using the latest software

If your software has expired.

Make sure that you are using the latest version of the following:

  1. Java - as far as possible using the latest 64-bit version of Java SE JDK or Server JRE
  2. JMeter - best to use the latest version of JMeter, because in addition to any new features, the new version also includes performance improvements and bug fixes.  
  3. JMeter plug-ins (or other third-party libraries) - Java and JMeter the same reason

 

3. Run the test in non-GUI mode

Never run load tests on JMeter GUI!

For testing records, development and debugging.

JMeter is not to produce a high load in GUI mode and design,

This means that it will not only freeze - but also consume large amounts of resources and produce unreliable load test results.

I recommend the command line mode,

Ant任务或Maven插件中运行负载测试 - 但从不使用GUI。

 

4.明智地使用监听器

在负载测试期间应禁用监听器。

启用它们会导致额外的开销,

这会占用测试中更重要元素所需的宝贵资源。

您可以在测试完成后使用所需的任何侦听器打开.jtl结果文件并执行其分析。

  

5.确定您需要存储哪些指标

配置JMeter以确保它只保存您绝对需要的指标。

您可以通过向user.properties文件添加相关行来控制要存储的内容(您可以在JMeter安装的/ bin文件夹中找到它)。 

 

JMeter index

 

例如:

使用Active Threads Over Time ListenerResponse Times vs Threads等监听器

您需要存储当前活动线程的数量(默认情况下不会这样做)。

要启用此功能,

您需要将“jmeter.save.saveservice.thread_counts = true”行添加到user.properties文件中。

同样,

要控制结果的保存方式,

请搜索jmeter.properties文件的Results File Configuration部分(您也可以在JMeter / bin文件夹中找到它)并检查名称开头的属性的名称和默认值用:“jmeter.save.saveservice”。

找出适当的配置后,

您可以通过指定需要存储哪些指标以及不需要哪些指标来修改user.properties文件。

不要忘记,

在存储请求和响应头时,

断言结果和响应数据会占用大量内存!

因此,

除非绝对必要,

否则尽量不要将这些值存储在JMeter上。  

  

6.选择“正确关联选项”

如果需要从先前的响应中提取某些内容,

请尝试使用正则表达式提取器

如果由于某种原因不可能(即您需要使用多行复杂正则表达式从HTML获取多个值),

请尝试以下方法之一:

  1. 如果页面有一个非常复杂的DOM,但样式的数量相对较少 - 请转到CSS / JQuery Extractor

  2. 如果样式数量很高且DOM非常简单 - 请使用XPath Extractor

如果你有足够的时间,

你可以为每个PostProcessor进行实验并获取内存占用量。

这将清楚地显示哪一个更好。

但请记住 - 由于不同的应用程序具有不同的响应,因此必须将此方法应用于每个页面。  

 

7.谨慎使用断言

添加到测试计划中的每个测试元素都将被处理 - 这需要CPU时间和内存。

这也适用于所有断言

对于比较断言尤其如此- 它消耗大量资源和内存。

只使用你需要的断言,

即使这样,

只需使用绝对需要的数量。

 

8.检查您的脚本语言

JMeter支持相当多的脚本语言。

但是,

如果您使用基于脚本的采样器来创建实际负载,

则需要使用JSR223采样器和“Groovy”作为语言。

 

9.“调整”你的JVM 

您还可以在JMeter启动脚本中添加或修改以下JVM参数:

    1. 在JMeter启动脚本中找到NEW =“ - XX:NewSize = 128m -XX:MaxNewSize = 128m”行。取消注释并增加值以匹配您为HEAP设置的值

    2. -server - 通过运行时参数优化将JVM切换到“服务器”模式。在这种模式下,JMeter启动速度更慢,但总体吞吐量会更高

    3. -d64 - If you have a 64-bit operating system, use this parameter to explicitly tell the JVM is running in 64-bit mode

    4. -XX: + UseConcMarkSweepGC - This forces the use of CMS garbage collector. It will reduce overall throughput, but will result in shorter CPU-intensive garbage collection.

    5. -XX: + DisableExplicitGC - This prevents an application from forcing expensive garbage collection, and helps avoid unexpected pause. If you think JMeter throughput may be better and it does not take full advantage of JVM, operating system and machine resources, try using JConsole or VisualVM to monitor and check the JMeter process heap size usage, GC interval, time spent in garbage system collection. Ideally, GC should look like healthy people, "Pulse." The garbage collector should always shooting to prevent the OOM - but not so much that it strongly felt the impact.

Guess you like

Origin www.cnblogs.com/yjlch1016/p/11257486.html