天天看點

搭建RocketMQ踩的坑-記憶體不足

環境是vmvare+ubuntu 

1、http://rocketmq.apache.org/docs/quick-start/ 按照官網來啟動mqnamesrv和mqbroker報錯 

錯誤如下 

there is insufficient memory for the java runtime environment to continue.

there is insufficient memory for the java runtime environment to continue.  

native memory allocation (mmap) failed to map 8589934592 bytes for committing reserved memory.  

possible reasons:  

the system is out of physical ram or swap space  

in 32 bit mode, the process size limit was hit  

possible solutions:  

reduce memory load on the system  

increase physical memory or swap space  

check if swap backing store is full  

use 64 bit java on a 64 bit os  

decrease java heap size (-xmx/-xms)  

decrease number of java threads  

decrease java thread stack sizes (-xss)  

set larger code cache with -xx:reservedcodecachesize=  

this output file may be truncated or incomplete.

out of memory error (os_linux.cpp:2640), pid=2428, tid=0x00007fada5259700

jre version: (8.0_172-b11) (build )  

java vm: java hotspot(tm) 64-bit server vm (25.172-b11 mixed mode linux-amd64 compressed oops) 

java運作時環境的記憶體不足,無法繼續,本機記憶體配置設定(mmap)未能映射8589934592位元組,用于送出保留記憶體 

解決辦法,找到runserver.sh和runbroker.sh,編輯 

#java_opt="${java_opt} -server -xms8g -xmx8g -xmn4g" (預設需要記憶體空間)

java_opt=”${java_opt} -server -xms256m -xmx256m -xmn125m -xx:metaspacesize=128m -xx:maxmetaspacesize=320m” 

改成如上就可以了