0%

Tomcat启动闪退Out of Memory Error

问题

Tomcat启动到一半闪退,bin目录下生成了hs_err_pidXXXX.log文件

日志内容如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 1660496 bytes for Chunk::new
# Possible reasons:
# The system is out of physical RAM or swap space
# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
# JVM is running with Unscaled Compressed Oops mode in which the Java heap is
# placed in the first 4GB address space. The Java Heap base address is the
# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress
# to set the Java Heap base and to place the Java Heap above 4GB virtual address.
# This output file may be truncated or incomplete.
#
# Out of Memory Error (allocation.cpp:390), pid=6684, tid=0x0000000000000df8
#
# JRE version: Java(TM) SE Runtime Environment (8.0_201-b09) (build 1.8.0_201-b09)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.201-b09 mixed mode windows-amd64 compressed oops)
# Failed to write core dump. Call to MiniDumpWriteDump() failed (Error 0x800705af: 页面文件太小,无法完成操作。

)

翻译过来就是本地内存分配失败, 可能的原因有两种

  1. 系统物理内存或虚拟内存不足
  2. 程序在压缩指针模式下运行, Java堆会阻塞本地堆的增长

解决方案

查看服务器,发现内存足够,尝试按第二个问题进行解决。

禁止使用压缩指针模式,在Catalina.bat中的JAVA_OPTS的值后面加

1
-XX:-UseCompressedOops