我正在Java jar上運行Amazon實例上的某個Web應用程序,但它在12小時左右後總是耗盡內存。以下是寫入文件的錯誤消息:在亞馬遜EC2上運行的Jar t2.micro實例內存不足
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實例升級到更大尺寸?
嗯..但錯誤消息是建議減少堆大小。 –
哦,我明白了。也許你已經分配了比服務器上實際存在更多的內存。無論如何,如果您需要更確切的建議,您需要提供當前的JVM設置。 –
如何獲取當前的JVM設置?我需要編寫一個Java程序嗎,還是可以從命令行執行? –