【发布时间】:2016-10-15 07:15:52
【问题描述】:
我的生产环境 webapp 出现内存问题。
我有一个在 AWS EC2 t2.medium 实例中运行的 Tomcat(2 核 cpu 64 位 + 4gb ram)。
这是来自 javamelody 的一些信息:
OS: OS Linux, 3.13.0-87-generic , amd64/64 (2 cores)
Java: Java(TM) SE Runtime Environment, 1.8.0_91-b14
JVM: Java HotSpot(TM) 64-Bit Server VM, 25.91-b14, mixed mode
Tomcat "http-nio-8080": Busy threads = 4 / 200 ++++++++++++
Bytes received = 8.051
Bytes sent = 206.411.053
Request count = 3.204
Error count = 70
Sum of processing times (ms) = 540.398
Max processing time (ms) = 12.319
Memory: Non heap memory = 130 Mb (Perm Gen, Code Cache),
Buffered memory = 0 Mb,
Loaded classes = 12,258,
Garbage collection time = 1,394 ms,
Process cpu time = 108,100 ms,
Committed virtual memory = 5,743 Mb,
Free physical memory = 142 Mb,
Total physical memory = 3,952 Mb,
Free swap space = 0 Mb,
Total swap space = 0 Mb
Free disk space: 27.457 Mb
我的申请进入:
内存不足,Java 运行时环境无法继续。 本机内存分配 (mmap) 未能映射 12288 字节以提交保留内存。
我已经应用了以下配置选项,但似乎又失败了。
导出 JAVA_OPTS="-Dfile.encoding=UTF-8 -Xms1024m -Xmx3072m -XX:PermSize=128m -XX:MaxPermSize=256m"
这个配置适合我的 linux 配置吗?
更多信息:我的数据库和文件系统正在另一个 t2.medium 实例中运行(Windows 2 cores cpu + 4gb ram)。
谢谢,对不起我的英语。
已编辑:
问题仍然存在。最奇怪的是,在日志中没有大进程在运行,而且时间已经过去了(所以很少有人连接到应用程序)。
过去,我在 Windows 环境中使用了该应用程序,但没有发生这种情况。我认为 Linux 实例会更好,但我快疯了。
日志:
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000f2d80000, 43515904, 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 43515904 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /home/ubuntu/hs_err_pid20233.log
现在我的配置是 setenv.sh:
export CATALINA_OPTS="-Dfile.encoding=Cp1252 -Xms2048m -Xmx2048m -server"
我不知道是否有意义,但 hs_err 文件有这一行:
内存:4k 页面,物理 4046856k(102712k 空闲),交换 0k(0k 空闲)
【问题讨论】:
标签: linux performance tomcat memory amazon-ec2