在看下文之前,首先要确认意见事情,就是你是怎样启动tomcat的,我们在平时的开发环境其中,都是通过startup.bat方式启动tomcat的,那么你依照以下的方式,去改动/bin/catalina.bat是没有问题的。可是假设你是生产环境下,我们一般都希望使用windows服务方式去启动tomcat,此时之前改动的配置文件是没实用的。由于windows服务启动tomcat不再去载入catalina.bat其中的參数了,而是去载入注冊表中的參数,所以我们须要改动注冊表。

HKEY_LOCAL_MACHINE/SOFTWARE/Apache Software Foundation/Procrun 2.0/Tomcat_APPNAME/Parameters/Java,改动JvmMs和JvmMx的值,当前我都将其设定为1024,也就是1个G的容量。详细性能再后面继续观察。 之前还真不知道windows服务启动和startup.bat启动的差别。 windowsserver启动是在注冊表中载入參数,startup.bat启动是在catalina.bat载入參数。

1.參考:

http://blog.csdn.net/fox009/article/details/5633007

http://hi.baidu.com/like_dark/blog/item/19c1948b3292b0799f2fb468.html

http://anyeeye.iteye.com/blog/444624

Tomcat6性能调优
出现java.lang.OutOfMemoryError: PermGen space

http://www.mkyong.com/tomcat/tomcat-javalangoutofmemoryerror-permgen-space/

2.报错:

Exception in thread "DispatcherThread" java.lang.OutOfMemoryError: PermGen space
Exception in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]" java.lang.OutOfMemoryError: PermGen space
Exception in thread "State Saver" java.lang.OutOfMemoryError: PermGen space
Exception in thread "AWT-Windows" java.lang.OutOfMemoryError: OutOfMemoryError

3.原因:

PermGen space的全称是Permanent Generation space,是指内存的永久保存区域,这块内存主要是被JVM存放Class和Meta信息的,Class在被Loader时就会被放到PermGen space中,它和存放类实例(Instance)的Heap区域不同,GC(Garbage Collection)不会在主程序执行期对PermGen space进行清理,所以假设你的应用中有非常多CLASS的话,就非常可能出现PermGen space错误,这样的错误常见在webserver对JSP进行pre
compile的时候。假设你的WEB APP下都用了大量的第三方jar, 其大小超过了jvm默认的大小(4M)那么就会产生此错误信息了。

4.解决方法1:

手动设置MaxPermSize大小,假设是linux系统,改动TOMCAT_HOME/bin/catalina.sh,假设是windows系统,改动TOMCAT_HOME/bin/catalina.bat,

在“echo "Using CATALINA_BASE: $CATALINA_BASE"”上面添�下面行:

JAVA_OPTS="-server -XX:PermSize=64M -XX:MaxPermSize=128m

建议:将同样的第三方jar文件移置到tomcat/shared/lib文件夹下,这样能够达到降低jar 文档反复占用内存的目的。

5.解决方法2

改动eclipse.ini文件,改动例如以下:

-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms128m
-Xmx512m
-XX:PermSize=64M
-XX:MaxPermSize=128M

假设还报错,能够考虑例如以下改动

-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms512m
-Xmx1024m
-XX:PermSize=256M
-XX:MaxPermSize=512M

报错:

2011-11-21 21:10:46 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [/Application] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
2011-11-21 21:10:46 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/Application] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak.
2011-11-21 21:10:46 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/Application] appears to have started a thread named [AWT-Windows] but has failed to stop it. This is very likely to create a memory leak.
2011-11-21 21:10:46 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/Application] appears to have started a thread named [Thread-14] but has failed to stop it. This is very likely to create a memory leak.
2011-11-21 21:10:46 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
严重: The web application [/Application] created a ThreadLocal with key of type [net.sf.json.AbstractJSON$1] (value [net.sf.json.AbstractJSON$1@3661eeb]) and a value of type [java.util.HashSet] (value [[]]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
2011-11-21 21:10:50 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring FrameworkServlet 'Dispatcher'

改动catalina.bat

加入�

JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8
-server -Xms1536m -Xmx1536m
-XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m
-XX:MaxPermSize=256m -XX:+DisableExplicitGC"

例子

#   JSSE_HOME       (Optional) May point at your Java Secure Sockets Extension
# (JSSE) installation, whose JAR files will be added to the
# system class path used to start Tomcat.
#
# CATALINA_PID (Optional) Path of the file which should contains the pid
# of catalina startup java process, when start (fork) is used
#
# $Id: catalina.sh 609438 2008-01-06 22:14:28Z markt $
# ----------------------------------------------------------------------------- JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms1536m
-Xmx1536m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m
-XX:MaxPermSize=256m -XX:+DisableExplicitGC" # OS specific support. $var _must_ be set to either true or false.
cygwin=false
os400=false
darwin=false
case "`uname`" in
CYGWIN*) cygwin=true;;
OS400*) os400=true;;
Darwin*) darwin=true;;
esac # resolve links - $0 may be a softlink
PRG="$0"

详细參数依据自己机器情况而定

JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms512m
-Xmx512m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m
-XX:MaxPermSize=256m -XX:+DisableExplicitGC"

PermGen space错误解决方法的更多相关文章

  1. java.lang.OutOfMemoryError: PermGen space错误解决方法

    1. MyEclipse 中报 PermGen space       window--> preferences-->Myclipse-->Servers-->Tomcat- ...

  2. java.lang.OutOfMemoryError: PermGen space及其解决方法(转载)

    java.lang.OutOfMemoryError: PermGen space及其解决方法 分类: java2007-09-11 12:34 162242人阅读 评论(51) 收藏 举报 gene ...

  3. 在Eclipse中运行Jboss时出现java.lang.OutOfMemoryError:PermGen space及其解决方法

    在Eclipse中运行Jboss时出现java.lang.OutOfMemoryError:PermGen space及其解决方法 在Eclipse中运行Jboss时,时间太长可能有时候会出现java ...

  4. java.lang.OutOfMemoryError: PermGen space及其解决方法

    PermGen space的全称是Permanent Generation space,是指内存的永久保存区域OutOfMemoryError: PermGen space从表面上看就是内存益出,解决 ...

  5. <<< PermGen space溢出解决方法

    错误信息中的PermGen space的全称是Permanent Generation space,是指内存的永久保存区域.还没有弄明白PermGen space是属于非堆内存,还是就是非堆内存,但至 ...

  6. [转]java.lang.OutOfMemoryError: PermGen space及其解决方法

    原文地址:http://peak.iteye.com/blog/52606 这个问题是我的工程中加入了Birt报表在Linux环境下运行出现的问题,从网上搜索了一下看到这文章发现并不是由于Birt的原 ...

  7. java.lang.OutOfMemoryError: PermGen space有效解决方法

    PermGen space的全称是Permanent Generation space,是指内存的永久保存区域OutOfMemoryError: PermGen space从表面上看就是内存益出,解决 ...

  8. myEclipse开发内存溢出解决办法myEclipse调整jvm内存大小java.lang.OutOfMemoryError: PermGen space及其解决方法

    摘要: tomcat部署多个项目后,启动tomcat正常,访问项目时却会出现该错误在网上查了查又试了好几次,才解决,将解决方法记录下来,以方便以后查看或让遇到同样问题的朋友有个参考 PermGen s ...

  9. Eclipse+Maven环境下java.lang.OutOfMemoryError: PermGen space及其解决方法

    转自  https://blog.csdn.net/qdgengwenfei/article/details/71455432 java.lang.OutOfMemoryError: PermGen ...

随机推荐

  1. 连接池dbcp pool

    -package cn.gdpe.pool; import java.io.InputStream;import java.sql.Connection;import java.sql.Prepare ...

  2. centos6.2下搭建Web服务器

    1.安装Apache2 yum install httpd 2.启动 方法一:service httpd start 方法二:/etc/init.d/httpd start //浏览http://ip ...

  3. uboot总结:uboot配置和启动过程1(主Makefile分析)

    说明:文件位置:在uboot的目录下,文件名为:Makefile 从文件的头部开始分析 1.24-29行,配置uboot的版本信息. VERSION = PATCHLEVEL = SUBLEVEL = ...

  4. 重装Ubuntu系统并配置开发环境

    安装 Ubuntu 并配置开发环境 写一篇文章详细记录下来所有的过程,以便以后参考. 安装前的准备 备份所有代码和配置文件 备份下载的各类文件 Ubuntu 安装 下载安装 Ubuntu14.04,下 ...

  5. 一个关于导出excel模板的实例

    1 首先jsp页面 点击模板下载,会自动下载模板excel,效果如下 让我们看源码: 1 jsp页面 <div class="tab-pane" id="profi ...

  6. jquery如何判断div是否隐藏--useful

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  7. 最简单理解CGI,FastCGI,WSGI

    CGI规定了如何执行本地脚本技术规范(协议),FastCGI规定了如何远程请求执行脚本的技术规范,WSGI规定了如何请求执行Python脚本的规范. 他们的相同点就是envionment variab ...

  8. Standard Numeric Format Strings

    The following table describes the standard numeric format specifiers and displays sample output prod ...

  9. Sereja ans Anagrams

    Codeforces Round #215 (Div. 1) B:http://codeforces.com/problemset/problem/367/B 题意:给你两个序列a,b,然后给你一个数 ...

  10. iOS cell自动换行

    // //  DynamicHeightsViewController.h //  DynamicHeights // //  Created by Matt Long on 9/22/09. //  ...