我正在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程序吗,还是可以从命令行执行? –