首页 技术 正文
技术 2022年11月9日
0 收藏 482 点赞 4,043 浏览 4549 个字

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/

https://blog.csdn.net/xw13106209/article/details/6996976

http://outofmemory.cn/c/java-outOfMemoryError

2.报错:

  1. Exception in thread “DispatcherThread” java.lang.OutOfMemoryError: PermGen space
  2. Exception in thread “ContainerBackgroundProcessor[StandardEngine[Catalina]]” java.lang.OutOfMemoryError: PermGen space
  3. Exception in thread “State Saver” java.lang.OutOfMemoryError: PermGen space
  4. 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错误,
这种错误常见在web服务器对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 文档重复占用内存的目的。

如果依然不行,请改为

JAVA_OPTS=”-server -XX:PermSize=256M -XX:MaxPermSize=512m

5.解决方法2

修改eclipse.ini文件,修改如下:

  1. -vmargs
  2. -Dosgi.requiredJavaVersion=1.5
  3. -Xms128m
  4. -Xmx512m
  5. -XX:PermSize=64M
  6. -XX:MaxPermSize=128M

如果还报错,可以考虑如下修改

  1. -vmargs
  2. -Dosgi.requiredJavaVersion=1.5
  3. -Xms512m
  4. -Xmx1024m
  5. -XX:PermSize=256M
  6. -XX:MaxPermSize=512M

报错:

  1. 2011-11-21 21:10:46 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
  2. 严重: 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.
  3. 2011-11-21 21:10:46 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
  4. 严重: 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.
  5. 2011-11-21 21:10:46 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
  6. 严重: 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.
  7. 2011-11-21 21:10:46 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
  8. 严重: 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.
  9. 2011-11-21 21:10:46 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
  10. 严重: 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.
  11. 2011-11-21 21:10:50 org.apache.catalina.core.ApplicationContext log
  12. 信息: Initializing Spring FrameworkServlet ‘Dispatcher’

修改catalina.bat

添加

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

样例

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

具体参数根据自己机器情况而定

    1. JAVA_OPTS=”-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms512m
    2. -Xmx512m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m
    3. -XX:MaxPermSize=256m -XX:+DisableExplicitGC”
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,492
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,494
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,132
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,295