码迷,mamicode.com
首页 > 其他好文 > 详细

jmeter报错:内存溢出

时间:2018-08-31 10:53:42      阅读:1539      评论:0      收藏:0      [点我收藏+]

标签:技术   结果   win   epo   删除   swap   脚本   long   最好   

使用jmeter进行压力测试时,经常会遇到内存溢出错误:

2018-08-28 09:01:26,686 ERROR o.a.j.JMeter: Uncaught exception: 

java.lang.OutOfMemoryError: Java heap space

技术分享图片

 

我们来看看官方文档如何解决这个问题:

官方文档1:https://wiki.apache.org/jmeter/ErrorMessages

Exception java.lang.OutOfMemoryError: requested nnnn bytes for promotion. Out of swap space?
Not enough memory was available to Java to run the test. There are numerous possible causes, the most likely is using Listeners that use a lot of memory, such as Aggregate Report and View Results Tree. You can increase the amount of memory by editting the jmeter.bat file or the jmeter shell script. Use non-GUI mode if possile. See...

中文解释:

java.lang.OutOfMemoryError异常:请求nnnn字节进行升级。 交换空间?
没有足够的内存可供Java运行测试。 有许多可能的原因,最有可能是添加了耗费大量内存的监听器,例如聚合报告和查看结果树。 您可以通过编辑jmeter.bat文件或jmeter shell脚本来增加内存量。 如果可能,请使用非GUI模式。 具体请查看 jmeter之最佳实践 中的16.7 减少资源需求:

关于减少资源使用的一些建议。

使用非GUI模式:jmeter -n -t test.jmx -l test.jtl
使用尽可能少的监听器:如果使用上面的-l标志,则可以删除或禁用它们。
在负载测试期间,请勿使用“查看结果树”或“View Results in Table”监听器,仅在脚本编写阶段使用它们来调试脚本。
在循环中对于相似的请求最好使用同一个采样器并使用变量(CSV Data Set)来区分,而不是使用多个相似的取样器。 [使用控制器在这里没有帮助,因为它会将文件中的所有测试元素添加到测试计划中。]
不要使用功能模式。
使用CSV输出而不是XML。
仅保存您需要的数据。
使用尽可能少的断言。
使用性能最佳的脚本语言(参见JSR223部分)。
如果您的测试需要大量数据 - 特别是如果需要随机化 - 请在可以用 CSV Dataset 读取的文件中创建测试数据。这可以避免在运行时浪费资源。

 

官方文档2:https://wiki.apache.org/jmeter/JMeterFAQ

JMeter keeps getting "Out of Memory" errors. What can I do?
This is usually caused by including memory intensive listeners in your stress test. Listeners like "View Tree Results" are useful for debugging your test, but they are too memory intensive to remain in your test when you ramp up the number of simulated users and iterations. The best listeners to use for a long-term, high-load test are Aggregate Listener, Graph Listener, and Spline Listener.
In addition, you can instruct the JVM to use more memory by editing the jmeter/jmeter.bat files for linux/windows. Within these files, find a section that sets values for the Heap:
• set HEAP=-Xms256m -Xmx256m
Feel free to change these values. Xms indicates the starting RAM the jvm will take, and Xmx will be the maximum it is allowed (for the HEAP).

中文解释:

JMeter不断出现“Out of Memory”错误。我能做什么?
这通常是由压力测试中包含内存密集型监听器引起的。 像“查看树结果”这样的监听器对于调试测试很有用,但是当你增加模拟用户和迭代次数时,它们的内存密集性太大而不能保留在测试中。 用于长期高负载测试的最佳侦听器是Aggregate Listener,Graph Listener和Spline Listener。
此外,您可以通过编辑linux/windows的jmeter.sh/jmeter.bat文件来指示JVM使用更多内存。在这些文件中,找到一个为Heap设置值的部分:
例如设置:HEAP = -Xms256m -Xmx256m
可根据测试机器实际内存情况来更改这些值。 Xms表示jvm将采用的起始RAM,Xmx将是允许的最大值(对于HEAP)。

 

官方文档3:http://jmeter.apache.org/usermanual/jmeter_distributed_testing_step_by_step.html

A single JMeter client running on a 2-3 GHz CPU (recent CPU) can handle 1000-2000 threads depending on the type of test.

中文解释:

在2-3 GHz CPU(目前的CPU)上运行的单个JMeter客户端可以处理1000-2000个线程,具体取决于测试类型。
所以当线程数过多时,可能你需要考虑使用分布式测试了。

 

jmeter报错:内存溢出

标签:技术   结果   win   epo   删除   swap   脚本   long   最好   

原文地址:https://www.cnblogs.com/zhengna/p/9554352.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!