不可行的方法
最初我直接修改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进程。

我的方式,参考上面参数设置启发,设置了-Xms1G -Xmn1G就好了,shutdown.sh就能用了

Linux下TomcatVM参数修改:Native memory allocation (mmap) failed to map 3221225472 bytes for committing reserved memory.的更多相关文章

  1. Native memory allocation (mmap) failed to map xxx bytes for committing reserved memory

    遇到问题 在服务器上运行 nexus 出现Native memory allocation (mmap) failed to map 838860800 bytes for committing re ...

  2. Native memory allocation (mmap) failed to map 142606336 bytes for committing reserved memory.

    这里写链接内容 问题描述 Java程序运行过程中抛出java.lang.OutOfMemoryError: unable to create new native thread,如下所示: [java ...

  3. linux 下tomcat出现 Native memory allocation (malloc) failed to allocate 1915224064 bytes for committing reserved memory问题

    ## There is insufficient memory for the Java Runtime Environment to continue.# Native memory allocat ...

  4. Linux下配置tomcat+apr+native应对高并发

    摘要:在慢速网络上Tomcat线程数开到300以上的水平,不配APR,基本上300个线程狠快就会用满,以后的请求就只好等待.但是配上APR之后,Tomcat将以JNI的形式调用Apache HTTP服 ...

  5. (转)Linux下配置tomcat+apr+native应对高并发

    摘要:在慢速网络上Tomcat线程数开到300以上的水平,不配APR,基本上300个线程狠快就会用满,以后的请求就只好等待.但是配上APR之后,Tomcat将以JNI的形式调用Apache HTTP服 ...

  6. Linux 下网卡参数配置

    目录 Linux 下网卡参数配置 第一种:修改 interfaces 文件 网卡配置实例 回环参数配置 DHCP方式配置 静态 IP 地址分配 无线网卡配置 March 17, 2015 7:48 P ...

  7. linux 下查看文件修改时间

    linux 下查看文件修改时间 等 http://blog.sina.com.cn/s/blog_6285b04e0100f4xr.html 查看文件时间戳命令:stat awk.txtFile: ` ...

  8. docker环境下mysql参数修改

    原文:docker环境下mysql参数修改 需要修改log_bin为on,看了好几个博客说都需要删掉容器重新生成,然而并非如此, 我们可以用docker cp 命令将docker的文件"下载 ...

  9. linux下C++遍历文件夹下的全部文件;Windows/Linux下C++批量修改文件名,批量删除文件

    Linux下 C++遍历目录下所有文件 rename(image_path.c_str(), image_path_new.c_str()); remove(image_path_move.c_str ...

随机推荐

  1. Ionic2学习笔记(7):Input

    作者:Grey 原文地址: http://www.cnblogs.com/greyzeng/p/5554610.html           我们先来看一个简单的输入用户名和密码点击登录的界面:   ...

  2. javascript设计模式实践之职责链--具有百叶窗切换图片效果的JQuery插件(三)

    在上一篇<javascript设计模式实践之模板方法--具有百叶窗切换图片效果的JQuery插件(二)>里,通过采用模板方法模式完成了切换效果对象的构建编写. 接下来就是完成各效果对象的调 ...

  3. ASP.NET MVC 之自定义HtmlHelper

    前言 HtmlHelper方法为我们提供很多html标签,只需在页面调用就行了,但是微软并没有把所有的html标签都对应有了扩展方法,需要我们重新自定义HtmlHelper,来满足我们需要. 方法 如 ...

  4. [Asp.net 5] Logging-日志系统的基本架构(上)

    本节主要介绍解决方案中的Microsoft.Framework.Logging.Abstractions.Microsoft.Framework.Logging俩个工程. 这俩个工程中所有类的关系如下 ...

  5. iOS学习笔记——使用ChildViewController

    之前在使用TableView的时候遇到过问题,需要使用另外的TableViewController来先存放TableView,原有的View则使用ViewContainer来引用TableViewCo ...

  6. jquery改变链接移上光标时的颜色实例

    效果体验http://hovertree.com/texiao/jquery/18/ 完整代码如下: <!DOCTYPE html> <html> <head> & ...

  7. [WCF编程]2.SOA概述

    一.SOA简介 1. SOA(面向服务架构)既是一种编程方式,也是软件开发的一种架构方法.根据这种架构方法,应用程序是由具有一定行为(称为服务)的功能单元组成的. 2. SOA的基本思想是构建一个粗粒 ...

  8. 谈I/O模型

    一个IO操作涉及两个系统对象: 调用这个IO的用户Process/Thread 系统内核 - System Kernel 一个具体的Read操作包括两个阶段: 内核等待数据准备就绪:Waiting f ...

  9. es6 中增强的对象字面量

    http://www.cnblogs.com/Wayou/p/es6_new_features.html 对象字面量被增强了,写法更加简洁与灵活,同时在定义对象的时候能够做的事情更多了.具体表现在: ...

  10. php中防止SQL注入的方法

    [一.在服务器端配置] 安全,PHP代码编写是一方面,PHP的配置更是非常关键. 我们php手手工安装的,php的默认配置文件在 /usr/local/apache2/conf/php.ini,我们最 ...