[英]Jar running on Amazon EC2 t2.micro instance runs out of memory
我正在通過Java jar在Amazon實例上運行一些Web應用程序,但是它總是在12小時左右后耗盡內存。 這是被寫入文件的錯誤消息:
There is insufficient memory for the Java Runtime Environment to continue.
Native memory allocation (malloc) failed to allocate 12288 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 backi ng 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:2827), pid=5808, tid=140367928600320
JRE version: OpenJDK Runtime Environment (7.0_95) (build 1.7.0_95-b00)
Java VM: OpenJDK 64-Bit Server VM (24.95-b01 mixed mode linux-amd64 compressed oops)
Derivative: IcedTea 2.6.4
Distribution: Ubuntu 14.04.3 LTS, package 7u95-2.6.4-0ubuntu0.14.04.1
Failed to write core dump. Core dumps have been disabled.
To enable core dumping, try "ulimit -c unlimited" before starting Java again
我如何從這里開始? 遵循他們的建議(例如增加堆大小或交換空間)是否有意義,還是我真的只需要將EC2實例升級到更大的大小?
您需要通過-Xmx
選項增加最大JVM堆大小設置,以允許JVM使用更多的內存。 如果需要將其增加到t2.micro實例上實際可用的數量之外,則還需要增加EC2實例的大小。
請記住,您將無法將t2.micro實例上的全部1GB內存分配給Java應用程序,因為其中一些將由操作系統使用。 另外,您還需要盡可能避免使用交換空間,因此請集中精力配置JVM以利用EC2實例上可用的RAM。
不知道當前的JVM設置是什么,很難給出更准確的建議。
問題是您用完了虛擬內存或實際地址空間。
這意味着您應該
您需要減少堆大小的原因是要為其余的JVM和系統留出更多內存
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.