前言
在 linux 上執行jmeter 代碼的時候遇到一個問題:There is insufficient memory for the Java Runtime Environment to continue.
報錯內容
在 windows 先執行過 get_info.jmx,正常運行,傳到 linux 上運行時遇到以下問題
[root@VM_0_2_centos ~]# jmeter -n -t get_info.jmx -l get.jtl
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c0000000, 1073741824, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 1073741824 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /root/hs_err_pid25736.log
從報錯可以應該是內存不夠用了,free -m
查看內存
[root@VM_0_2_centos ~]# free -m
total used free shared buff/cache available
Mem: 3789 3295 152 12 341 179
Swap: 2047 2047 0
果然 free 內存只有 152 了
解決辦法
先清理掉一些不用的進程,釋放一些內存出來,再次查看,大於1G,基本上沒啥問題了
[root@VM_0_2_centos easymock]# free -m
total used free shared buff/cache available
Mem: 3789 2390 875 12 524 1084
Swap: 2047 1478 569
再次運行
[root@VM_0_2_centos ~]# jmeter -n -t get_info.jmx -l get.jtl
Creating summariser <summary>
Created the tree successfully using get_info.jmx
Starting the test @ Sat May 30 17:01:31 CST 2020 (1590829291939)
Waiting for possible Shutdown/StopTestNow/HeapDump/ThreadDump message on port 4445
summary + 1 in 00:00:00 = 2.8/s Avg: 107 Min: 107 Max: 107 Err: 0 (0.00%) Active: 1 Started: 1 Finished: 0
summary + 299 in 00:00:03 = 86.8/s Avg: 29 Min: 10 Max: 224 Err: 0 (0.00%) Active: 0 Started: 3 Finished: 3
summary = 300 in 00:00:04 = 79.0/s Avg: 30 Min: 10 Max: 224 Err: 0 (0.00%)
Tidying up ... @ Sat May 30 17:01:36 CST 2020 (1590829296290)
... end of run