在給一個項目作穩定性測試中,也就是長時間運行jmeter,發現兩個問題:java
1,在聚合報告中,throuhtput隨着時間的增長也減少,從80-50.。。非常迷惑。linux
2,在jmeter運行一段時間,大概是1小時左右,jmeter 就crash.apache
查看bin目錄下的jmeter.log發現報如下錯誤windows
ERROR - jmeter.threads.JMeterThread: Error processing Assertion Java.lang.OutOfMemoryError: Java heap spaceapp
at java.util.Arrays.copyOf(Arrays.java:2367)jvm
at java.lang.StringCoding.safeTrim(StringCoding.java:89)測試
at java.lang.StringCoding.access$100(StringCoding.java:50)google
at java.lang.StringCoding$StringDecoder.decode(StringCoding.java:154)spa
at java.lang.StringCoding.decode(StringCoding.java:193).net
at java.lang.String.<init>(String.java:416)
at java.lang.String.<init>(String.java:481)
因而google解決方法,看到的解決方法,原文以下:
-----------
使用jmeter進行壓力測試時遇到一段時間後報內存溢出outfmenmory錯誤,致使jmeter卡死了,先嚐試在jmeter.bat中增長了JVM_ARGS="-Xmx2048m -Xms2048m -Xmn256m -XX:PermSize=128m -Xss256k",但結果運行時間增長了,但最終仍是報內存溢出,百度後按照網友的建議更改了以下設置後jmeter就沒有再卡了:
windows環境下,修改jmeter.bat:
因而我按着此方法設置了一翻,以後測試一段時間,錯誤仍是同樣。我想到了jconsole監測jmetere內存,發如今測試過程當中堆內存一直是上升狀態,這是內存溢出緣由!爲何呢,?就好像測試有什麼不斷的寫到內存。接着google,在官方wiki的文檔發現問題所在:
------
https://wiki.apache.org/jmeter/JMeterFAQ
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:
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).
------------
這提醒應該是‘查看結果樹’問題!因而刪除掉這個listerner,這是在腳本調試的時候用的,調試好了刪除掉吧。從新開跑!
再用jconsole監控,內存不會一直遞增!jmeter也不報outmemory的錯誤了!到此問題解決。