目前,我正在尝试使用10个用户并行运行我们的功能测试(大约300个请求) gatling-plugin
mvn clean test-compile gatling:test -Dkarate.env=test
.mvn/jvm.config
在项目文件夹中具有以下本地maven选项:
-d64 -Xmx4g -Xms1g -XshowSettings:vm -Djava.awt.headless=true
在并行处理一些大响应的某个时刻,加特林过程中止了:
[ERROR] Failed to execute goal io.gatling:gatling-maven-plugin:3.0.2:test (default-cli) on project np.rest-testing: Gatling failed.: Process exited with an error: -1 (Exit value: -1) -> [Help 1]
具有以下堆栈跟踪:
java.lang.OutOfMemoryError: Java heap space
Dumping heap to java_pid25960.hprof ...
Heap dump file created [1611661680 bytes in 18.184 secs]
Uncaught error from thread [GatlingSystem-scheduler-1]: Java heap space, shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[GatlingSystem]
java.lang.OutOfMemoryError: Java heap space
at akka.actor.LightArrayRevolverScheduler$$anon$3.nextTick(LightArrayRevolverScheduler.scala:269)
at akka.actor.LightArrayRevolverScheduler$$anon$3.run(LightArrayRevolverScheduler.scala:235)
at java.lang.Thread.run(Thread.java:748)
我尝试以-Xmx10g
不同的方式将堆空间增加到10 GB():
MAVEN_OPTS=-Xmx10g
.mvn/jvm.config
maven-surefire-plugin
建议的配置正如您在maven流程开始时看到的那样,尽管为maven流程分配了10GB:
VM settings:
Min. Heap Size: 1.00G
Max. Heap Size: 10.00G
Ergonomics Machine Class: client
Using VM: Java HotSpot(TM) 64-Bit Server VM
但OutOfMemoryError
在每次gatling-plugin
执行期间仍会抛出。
分析每个堆转储时,eclipse memory analyzer
总是显示相同的结果:
84 instances of "com.intuit.karate.core.StepResult", loaded by "sun.misc.Launcher$AppClassLoader @ 0xc0000000" occupy 954 286 864 (90,44 %) bytes.
Biggest instances:
•com.intuit.karate.core.StepResult @ 0xfb93ced8 - 87 239 976 (8,27 %) bytes...
如何减少堆空间并防止使用OutOfMemoryError
?有人可以分享一些想法和经验吗?
经过一些调查,我终于注意到,堆转储始终显示为1GB。这意味着不会使用增加的堆空间gatling-plugin
。
通过向插件添加以下jvm参数,即使使用4GB,也可以解决该问题:
<jvmArgs>
<jvmArg>-Xmx4g</jvmArg>
</jvmArgs>
因此,通过以下gatling-plugin
配置,该错误不再出现:
<plugin>
<groupId>io.gatling</groupId>
<artifactId>gatling-maven-plugin</artifactId>
<version>${gatling.plugin.version}</version>
<configuration>
<simulationsFolder>src/test/java</simulationsFolder>
<includes>
<include>performance.test.workflow.WorkflowSimulation</include>
</includes>
<compilerJvmArgs>
<compilerJvmArg>-Xmx512m</compilerJvmArg>
</compilerJvmArgs>
<jvmArgs>
<jvmArg>-Xmx4g</jvmArg>
</jvmArgs>
</configuration>
</plugin>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句