gpt4 book ai didi

linux - 生成报告时通过 jenkins Out of Memory 错误运行 Jmeter 脚本

转载 作者:太空宇宙 更新时间:2023-11-04 11:44:47 24 4
gpt4 key购买 nike

我在通过 Jenkins 运行 Jmeter 脚本时遇到内存不足问题。这个过程是在框架中编写的代码将生成的 XML 文件结果转换为 CSV,然后转换为 HTML 以在仪表板中发布报告。

我已经尝试将 Jenkins 服务器的堆空间 pf 增加到 32 GB 中的 25 GB。似乎最初它需要 1 Gb 然后在一段时间后它抛出错误,即使它在堆中仍有 24 GB pf 内存可用,我为此运行 free -h。

还尝试增加 Jmeter 内存设置 HEAP=-Xms1g -Xmx8g -XX:MaxMetaspaceSize=512m

该脚本在 Windows 上的 Jnekins 服务器中执行良好。但是当 jenkin 服务器处于 Linux 模式时它会抛出错误。

听到的是我的错误日志。

/var/lib/jenkins/workspace/ITT2_Execution/Resources/csvReportPath/ITT2_Unicast_Broker_Download_count.xml/var/lib/jenkins/workspace/ITT2_Execution/Resources//Configuration/transformGaurav.xsl/var/lib/jenkins/workspace/ITT2_Execution/jmeter_reports/ITT2_Unicast_Broker_Download_2_Oct_2019_19_3_52_Count.html{titleReport=ITT2_Unicast_Broker_DownloadCountReport, dateReport=2-Oct-2019 22:02:38}
Finished Parsing
/var/lib/jenkins/workspace/ITT2_Execution/Resources/csvReportPath/AutomationReport_5.2.4.2018.20_2_Oct_2019_19_3_52_count.xml/var/lib/jenkins/workspace/ITT2_Execution/Resources//Configuration/transformGaurav.xsl/var/lib/jenkins/workspace/ITT2_Execution/jmeter_reports/AutomationReport_5.2.4.2018.20_2_Oct_2019_19_3_52.html{titleReport=nullCountReport, dateReport=2-Oct-2019 22:02:39}
JVMDUMP039I Processing dump event "systhrow", detail "java/lang/OutOfMemoryError" at 2019/10/02 18:33:10 - please wait.
JVMDUMP039I Processing dump event "systhrow", detail "java/lang/OutOfMemoryError" at 2019/10/02 18:33:10 - please wait.
JVMDUMP032I JVM requested Heap dump using '/var/lib/jenkins/workspace/ITT2_Execution/heapdump.20191002.183310.40181.0001.phd' in response to an event
JVMDUMP010I Heap dump written to /var/lib/jenkins/workspace/ITT2_Execution/heapdump.20191002.183310.40181.0001.phd
JVMDUMP032I JVM requested System dump using '/var/lib/jenkins/workspace/ITT2_Execution/core.20191002.183310.40181.0002.dmp' in response to an event
JVMDUMP010I System dump written to /var/lib/jenkins/workspace/ITT2_Execution/core.20191002.183310.40181.0002.dmp
JVMDUMP032I JVM requested Java dump using '/var/lib/jenkins/workspace/ITT2_Execution/javacore.20191002.183310.40181.0003.txt' in response to an event
JVMDUMP010I Java dump written to /var/lib/jenkins/workspace/ITT2_Execution/javacore.20191002.183310.40181.0003.txt
JVMDUMP032I JVM requested Snap dump using '/var/lib/jenkins/workspace/ITT2_Execution/Snap.20191002.183310.40181.0005.trc' in response to an event
JVMDUMP010I Snap dump written to /var/lib/jenkins/workspace/ITT2_Execution/Snap.20191002.183310.40181.0005.trc
JVMDUMP013I Processed dump event "systhrow", detail "java/lang/OutOfMemoryError".
JVMDUMP032I JVM requested Heap dump using '/var/lib/jenkins/workspace/ITT2_Execution/heapdump.20191002.183310.40181.0004.phd' in response to an event
JVMDUMP010I Heap dump written to /var/lib/jenkins/workspace/ITT2_Execution/heapdump.20191002.183310.40181.0004.phd
JVMDUMP032I JVM requested Java dump using '/var/lib/jenkins/workspace/ITT2_Execution/javacore.20191002.183310.40181.0006.txt' in response to an event
JVMDUMP010I Java dump written to /var/lib/jenkins/workspace/ITT2_Execution/javacore.20191002.183310.40181.0006.txt
JVMDUMP032I JVM requested Snap dump using '/var/lib/jenkins/workspace/ITT2_Execution/Snap.20191002.183310.40181.0007.trc' in response to an event
JVMDUMP010I Snap dump written to /var/lib/jenkins/workspace/ITT2_Execution/Snap.20191002.183310.40181.0007.trc
JVMDUMP013I Processed dump event "systhrow", detail "java/lang/OutOfMemoryError".
[WARNING]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:508)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
at java.lang.Thread.run(Thread.java:811)
Caused by: java.lang.OutOfMemoryError: Java heap space
at org.apache.xerces.xni.XMLString.toString(Unknown Source)
at org.apache.xerces.parsers.AbstractDOMParser.characters(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanCharReference(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at utils.APIReportProcessing.fetchAPIReportDetailModuleWise(APIReportProcessing.java:110)
at jmeterRun.RunProcess.prepareFinalResultsMerged(RunProcess.java:228)
at jmeterRun.ControllerJMeter.main(ControllerJMeter.java:139)
... 6 more
[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.MavenArtifactArchiver$2; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.MavenFingerprinter$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/

谢谢比贝克

最佳答案

JMeter 进程在各种设置和参数下在 Java 虚拟机 (JVM) 中运行。 Java 堆空间(如错误消息中所指)是 JVM 从底层操作系统获取的内存,用于为创建必要的对象分配空间。

JMeter 的默认配置(请参阅 Windows 的 jmeter.bat 或非 Windows 系统脚本的 jmeter)假定堆空间仅为 512 兆字节。考虑到许多现代智能手机的容量是原来的四倍,这实际上是相当低的!如果您的测试正在运行超过 512Mb 的大量对象,您将收到 OOM 错误并且您的测试将失败。

幸运的是,有一个简单的解决方案。只需将最大堆大小增加到总可用物理 RAM 的 80% 左右。为此,请在 JMeter 启动脚本中找到以下行:

HEAP="-Xms1g -Xmx25g"

现在相应地更改 -Xmx 值。例如:如果要将最大堆大小设置为 25 GB,则需要将行更改为:

HEAP="-Xms1g -Xmx25g"

要应用更改,您需要重新启动 JMeter。

关于linux - 生成报告时通过 jenkins Out of Memory 错误运行 Jmeter 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58214036/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com