tomcat内存溢出问题解决思路

1、修改启动时内存参数、并指定JVM时区 (在windows server 2008 下时间少了8个小时)在Tomcat上运行j2ee项目代码时,经常会出现内存溢出的情况,解决办法是在系统参数中增加系统参数: window下, 在catalina.bat最前面:
set JAVA_OPTS=-XX:PermSize=64M -XX:MaxPermSize=128m -Xms512m -Xmx1024m
一定加在catalina.bat最前面。linux下,在catalina.sh最前面增加:JAVA_OPTS="-XX:PermSize=64M -XX:MaxPermSize=128m -Xms512m -Xmx1024m -Duser.timezone=Asia/Shanghai"注意:前后二者区别,有无set,有无双引号。2、线程池配置(Tomcat6下)使用线程池,用较少的线程处理较多的访问,可以提高tomcat处理请求的能力。使用方式:首先。打开/conf/server.xml,增加<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"maxThreads="500" minSpareThreads="20" maxIdleTime="60000" />最大线程500(一般服务器足以),最小空闲线程数20,线程最大空闲时间60秒。然后,修改<Connector ...>节点,增加executor属性,如:<Connector executor="tomcatThreadPool"port="80" protocol="HTTP/1.1"connectionTimeout="60000"keepAliveTimeout="15000"maxKeepAliveRequests="1"redirectPort="443"....../>注意:可以多个connector公用1个线程池。3、调整连接相关Connector的参数:<Connector executor="tomcatThreadPool"port="80" protocol="HTTP/1.1"connectionTimeout="60000"keepAliveTimeout="15000"maxKeepAliveRequests="1"redirectPort="443"maxHttpHeaderSize="8192" URIEncoding="UTF-8" enableLookups="false" acceptCount="100" disableUploadTimeout="true"/>参数说明:
connectionTimeout - 网络连接超时,单位:毫秒。设置为0表示永不超时,这样设置有隐患的。通常可设置为30000毫秒。
keepAliveTimeout - 长连接最大保持时间(毫秒)。此处为15秒。
maxKeepAliveRequests - 最大长连接个数(1表示禁用,-1表示不限制个数,默认100个。一般设置在100~200之间) the maximum number of HTTP requests that can be held in the pipeline until the connection is closed by the server. Setting this attribute to 1 disables HTTP/1.0 keep-alive, as well as HTTP/1.1 keep-alive and pipelining. Setting this to -1 allows an unlimited number of pipelined or keep-alive HTTP requests. If not specified, this attribute is set to 100.
maxHttpHeaderSize - http请求头信息的最大程度,超过此长度的部分不予处理。一般8K。
URIEncoding - 指定Tomcat容器的URL编码格式。
acceptCount - 指定当所有可以使用的处理请求的线程数都被使用时,可以放到处理队列中的请求数,超过这个数的请求将不予处理,默认为10个。defines the maximum queue length for incoming connection requests when all possible request processing threads are in use. Any requests received when the queue is full are refused. The default value is 10.
disableUploadTimeout - 上传时是否使用超时机制
enableLookups - 是否反查域名,取值为:true或false。为了提高处理能力,应设置为false
bufferSize - defines the size (in bytes) of the buffer to be provided for input streams created by this connector. By default, buffers of 2048 bytes are provided.
maxSpareThreads - 做多空闲连接数,一旦创建的线程超过这个值,Tomcat就会关闭不再需要的socket线程 the maximum number of unused request processing threads that are allowed to exist until the thread pool starts stopping the unnecessary threads. The default value is 50.
maxThreads - 最多同时处理的连接数,Tomcat使用线程来处理接收的每个请求。这个值表示Tomcat可创建的最大的线程数。。 the maximum number of request processing threads to be created by this Connector, which therefore determines the maximum number of simultaneous requests that can be handled. If not specified, this attribute is set to 200.
minSpareThreads - 最小空闲线程数,Tomcat初始化时创建的线程数 the number of request processing threads that are created when this Connector is first started. The connector will also make sure it has the specified number of idle processing threads available. This attribute should be set to a value smaller than that set for maxThreads. The default value is 4.
minProcessors - 最小空闲连接线程数,用于提高系统处理性能,默认值为10。(用于Tomcat4中)
maxProcessors - 最大连接线程数,即:并发处理的最大请求数,默认值为75。(用于Tomcat4中)
备注:Tomcat4中可以通过修改minProcessors和maxProcessors的值来控制线程数。在Tomcat5+主要对以下参数调整
maxThreadsTomcat使用线程来处理接收的每个请求。这个值表示Tomcat可创建的最大的线程数。acceptCount指定当所有可以使用的处理请求的线程数都被使用时,可以放到处理队列中的请求数,超过这个数的请求将不予处理。connnectionTimeout网络连接超时,单位:毫秒。设置为0表示永不超时,这样设置有隐患的。通常可设置为30000毫秒。minSpareThreadsTomcat初始化时创建的线程数。maxSpareThreads一旦创建的线程超过这个值,Tomcat就会关闭不再需要的socket线程。  4、负载均衡、集群的配置Tomcat6支持分布式部署,可以实现集群功能,提高响应能力。5、利用JMX监控Tomcat运行情况,需要手工调整启动参数,如下:打开cataline.bat,增加一行set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.port=10090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file="%CATALINA_BASE%\conf\logging.properties"linux下修改cataline.sh:
JAVA_OPTS="-Dcom.sun.management.jmxremote.port=10090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=%CATALINA_BASE\conf\logging.properties"注意JDK\jre\lib\management\management.properties文件必须存在。重新启动tomcat节点,然后用jconsole连接(此处端口wei10090)6、Tomcat增加一个应用在server.xml的Host标签中增加行<Context displayName="OA" docBase="/app/web-apps/GACWP" path="" />path代表上下文名称,空表示是根路径。转载地址:http://blog.sina.com.cn/cchao06

 

版权声明:本文为博主原创文章,未经博主允许不得转载。

转载于:https://www.cnblogs.com/weiguo21/p/4824021.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/473599.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

网站部署nginx--uwsgi

网站代码写完之后就是项目部署&#xff0c;主要包括两个方面&#xff1a; 1.nginx安装与配置&#xff1a; 1、Nginx 安装 系统平台&#xff1a;CentOS release 6.6 (Final) 64位。 一、安装编译工具及库文件 yum -y install make zlib zlib-devel gcc-c libtool openssl open…

天池 在线编程 滑动数独(滑动窗口)

文章目录1. 题目2. 解题1. 题目 描述 给定一个 3xn的矩阵 number&#xff0c;并且该矩阵只含有1到9的正整数。 考虑有一个大小为 3x3 滑动窗口&#xff0c;从左到右遍历该矩阵 number&#xff0c; 那么该滑动窗口在遍历整个矩阵的过程中会有n-2个。 现在你的任务是找出这些滑…

TIGK监控平台介绍

1 概述 众所周知监控平台对大数据平台是非常重要的&#xff0c;监控是故障诊断和分析的重要辅助利器&#xff0c;在发生事故之前就能预警&#xff0c;最大限度降低系统故障率。   监控系统我们可以分为业务层面&#xff0c;应用层面&#xff0c;系统层面 1.1 业务层面 业务系…

有意思的网站

谱聚类 http://blog.pluskid.org/?p287 Qt Graphics View 框架 http://yleesun.blog.163.com/blog/static/2941340220096110165817/ 谷歌编码规范 http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml 匈牙利命名法 http://blog.csdn.net/buglu/article/details/…

天池 在线编程 队列检查(排序)

文章目录1. 题目2. 解题1. 题目 描述 班上的学生根据他们的年级照片的身高升序排列&#xff0c;确定当前未站在正确位置的学生人数 数组长度 < 10^5示例 输入: heights [1,1,3,3,4,1]输出: 3解释: 经过排序后 heights变成了[1,1,1,3,3,4]&#xff0c;有三个学生不在应在…

celery异步执行任务在Django中的应用实例

1. 创建django项目celery_demo, 创建应用demo: django-admin startproject celery_demo python manage.py startapp demo2.在celery_demo模块中创建celery.py模块, 文件目录为: celery.py模块内容为: from celery import Celery from django.conf import settings import os#…

Spring自学教程-注解的使用(三)

一、java中的注解定义注解下面是一个定义注解的实例。Target(ElementType.TYPE)Retention(RetentionPolicy.RUNTIME)DocumentedInheritedpublic interface Description { String value();}其中的interface是一个关键字&#xff0c;在设计annotations的时候必须把一个类型定义为…

Django单元测试

一.前言/准备 测Django的东西仅限于在MTV模型。哪些可以测&#xff1f;哪些不可以。 1.html里的东西不能测。①Html里的HTML代码大部分都是写死的②嵌套在html中的Django模板语言也不能测&#xff0c;即使有部分逻辑。 但写测试用例时至少要调用一个类或者方法。模板语言没有出…

Telegraf安装及使用

1 安装 1.1 创建用户 &#xff08;1&#xff09;添加用户 # useradd tigk # passwd tigk Changing password for user tigk. New password: BAD PASSWORD: The password is shorter than 8 characters Retype new password: passwd: all authentication tokens updated suc…

天池 在线编程 中位数

文章目录1. 题目2. 解题1. 题目 描述 给定一个长度为N的整数数组arr 返回一个长度为N的整数答案数组ans ans[i] 表示删除arr数组第i个数后&#xff0c;arr数组的中位数 N为偶数 2 < N < 10^5 示例 输入:[1,2,3,4,5,6] 输出:[4,4,4,3,3,3] 解释:删去1后 剩下的数组为[…

自动化运维Shell课堂笔记

1、课程回顾 2、课程大纲 1、shell编程 开发和运维 shell基础知识 shell变量 shell表达式 shell流程控制语句 2、代码发布 项目周期 代码部署的方式 代码部署流程 服务器环境部署 手工方式部署代码 脚本方式部署代码 3、shell 3.1、开发和运维 3.1.1 开发 开发是什么&…

InfluxDB安装及使用

1 安装 1.1 Tar包安装 &#xff08;1&#xff09;获取tar包 wget https://dl.influxdata.com/influxdb/releases/influxdb-1.8.0_linux_amd64.tar.gz&#xff08;2&#xff09;解压tar包   tar xvfz influxdb-1.8.0_linux_amd64.tar.gz $ su - tigk $ tar xvfz /opt/packa…

倒排索引原理和实现

关于倒排索引 搜索引擎通常检索的场景是&#xff1a;给定几个关键词&#xff0c;找出包含关键词的文档。怎么快速找到包含某个关键词的文档就成为搜索的关键。这里我们借助单词——文档矩阵模型&#xff0c;通过这个模型我们可以很方便知道某篇文档包含哪些关键词&#xff0c;某…

天池 在线编程 Character deletion

文章目录1. 题目2. 解题1. 题目 描述 Enter two strings and delete all characters in the second string from the first string 字符串长度&#xff1a;[1, 10^5] Example 1: Input: str”They are students”&#xff0c;sub”aeiou” Output: ”Thy r stdnts”来源&am…

【翻译】在Ext JS中创建特定主题的重写

Ext JS提供了大量的功能来使类的创建和处理变得简单&#xff0c;还提供了一系列的功能来扩展和重新现有的Javascript类。这意味着可以为类添加行为和创建属于自己的类&#xff0c;或者重写某些函数的行为。在本文&#xff0c;将展示如何实现特定主题类的重写。原文&#xff1a;…

Kapacitor安装及使用

1 安装 1.1 Tar包安装 &#xff08;1&#xff09;下载 wget https://dl.influxdata.com/kapacitor/releases/kapacitor-1.5.5_linux_amd64.tar.gz&#xff08;2&#xff09;安装 $ tar xvfz /opt/package/kapacitor-1.5.5-static_linux_amd64.tar.gz -C /home/tigk/.local/ …

Python答题:LinteCode简单题库(一)

366. 斐波纳契数列&#xff1a;查找斐波纳契数列中第 N 个数。 所谓的斐波纳契数列是指&#xff1a; 前2个数是 0 和 1 。 第 i 个数是第 i-1 个数和第i-2 个数的和。 斐波纳契数列的前10个数字是&#xff1a; 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 ... 给定 1&#xff0c;返回 …

天池 在线编程 扫雷(BFS)

文章目录1. 题目2. 解题1. 题目 描述 现在有一个简易版的扫雷游戏&#xff0c;你将得到一个n*m大小的二维数组作为游戏地图。 每个位置上有一个值&#xff08;0或1&#xff0c;1代表此处没有雷&#xff0c;0表示有雷&#xff09;。 你将获得一个起点的位置坐标&#xff08;x&a…

Linux搭建高并发高可用Redis集群

安装Redis Redis 是一个高性能的key-value数据库。常用作缓存服务器使用。 1. 下载redis安装包&#xff0c;redis-3.2.11.tar.gz&#xff08;http://download.redis.io/releases/redis-3.2.11.tar.gz&#xff09; > wget http://download.redis.io/releases/redis-3.2.11.…

Flink简介

1 什么是Flink Apache Flink 是一个框架和分布式处理引擎&#xff0c;用于在无边界和有边界数据流上进行有状态的计算。Flink 能在所有常见集群环境中运行&#xff0c;并能以内存速度和任意规模进行计算。 它的主要特性包括&#xff1a;批流一体化、精密的状态管理、事件时间支…