Linux下Tomcat VM参数修改
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
免费下载资源
·
不可行的方法
最初我直接修改catalina.sh
, 将JAVA_OPTS
变量加上了
-server -Xms1G -Xmx1G -XX:+UserG1GC
最初看起来没啥问题,但是当服务器运行几天后,发现执行shutdown.sh
无法关闭tomcat, 错误信息如下:
# root@iZ94hjppdqzZ:~/projects/taolijie# cat hs_err_pid5519.log
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 1073741824 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 backing 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:2673), pid=5519, tid=3061726064
#
# JRE version: (8.0_45-b14) (build )
# Java VM: Java HotSpot(TM) Server VM (25.45-b02 mixed mode linux-x86 )
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
关闭个tomcat要请求1G的内存, 当时服务器就剩下200M内存,所以Out Of Memory了。查看shutdown.sh
,发现它其实还是调用了catalina.sh
,只是传入了一个stop
参数。而catalina.sh
是执行了
org.apache.catalina.startup.Bootstrap stop
来向tomcat发送关闭信息的。由于上面我们设置了JAVA_OPTS
使用1G的堆,因此执行该类时JVM会向系统申请1G多的内存,直接导致Out Of Memory。
可行的方法
在catalina.sh
的第二行添加:
CATALINA_OPTS="$CATALINA_OPTS -server -Xms1G -Xmx1G -XX:+UseG1GC"
这些VM参数就会只应用到catalina而不是所有Tomcat进程。
GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
已为社区贡献3条内容
所有评论(0)