eclipse PermGen spaceエラー解決方法


1.参考:
http://blog.csdn.net/fox009/article/details/5633007
http://hi.baidu.com/like_dark/blog/item/19 c 1948 b 3292 f 2 fb 468.html
http://anyeeye.iteye.com/blog/444624
Tomcat 6性能の優れた調子でjava.lang.OutOfMemoryErrが現れます.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はPerm期間中に実行されません.)ですから、あなたのアプリケーションに多くのCLASSがあると、PermGen spaceエラーが発生する可能性があります.このようなエラーはウェブサーバでJSPをpre compleする時によくあります.あなたのWEBアプリで大量の第三者jarを使っていたら、その大きさはjvmのデフォルトの大きさ(4 M)を超えています.このエラーメッセージが発生します.
4.解決方法1: 
手動でMaxPermSizeサイズを設定し、もしlinuxシステムであれば、TOMCAT_を修正します.HOME/bin/catalina.shは、windowsシステムであれば、TOMCAT_を修正します.HOME/bin/catalina.batは、「echo」「Using CATALINE A BASE:$CATALINE A BASE」に次の行を追加します.JAVA_OPETS="-server-XX:PermSize=64 M-XX:MaxPermSize=128 m提案:同じ第三者jarファイルをtomcat/shard/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"
 
 
 
作者:xwdreamer
出典:http://www.cnblogs.com/xwdreamer
いかなる形式の転載を歓迎しますが、必ず出典を明記してください.