Exception in thread "http-bio-8081-exec-3" java.lang.OutOfMemoryError: PermGen space


前言:

http://www.cnblogs.com/wql025/p/4865673.html一文中我曾描述這種異常也提供了解決方式,但效果不太理想,現在用本文的方式,效果顯著。

目前此項目只能登錄,再打開其他功能模塊即出現以下異常:

Exception in thread "http-bio-8081-exec-3" java.lang.OutOfMemoryError: PermGen space
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.eclipse.jdt.internal.compiler.classfmt.MethodInfo.decodeLocalVariableAttribute(MethodInfo.java:529)
at org.eclipse.jdt.internal.compiler.classfmt.MethodInfo.decodeCodeAttribute(MethodInfo.java:511)
at org.eclipse.jdt.internal.compiler.classfmt.MethodInfo.readCodeAttribute(MethodInfo.java:482)
at org.eclipse.jdt.internal.compiler.classfmt.MethodInfo.getArgumentNames(MethodInfo.java:251)
at org.eclipse.jdt.internal.compiler.classfmt.MethodInfo.initialize(MethodInfo.java:349)
at org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.initialize(ClassFileReader.java:1153)
at org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.<init>(ClassFileReader.java:388)
at org.apache.jasper.compiler.JDTCompiler$1.findType(JDTCompiler.java:231)
at org.apache.jasper.compiler.JDTCompiler$1.findType(JDTCompiler.java:203)
at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:157)
at org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:201)
at org.eclipse.jdt.internal.compiler.lookup.Scope.getPackage(Scope.java:2982)
at org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference.getTypeBinding(QualifiedTypeReference.java:97)
at org.eclipse.jdt.internal.compiler.ast.TypeReference.internalResolveType(TypeReference.java:472)
at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveType(TypeReference.java:571)
at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveType(TypeReference.java:567)
at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveSuperType(TypeReference.java:541)
at org.eclipse.jdt.internal.compiler.lookup.ClassScope.findSupertype(ClassScope.java:1287)
at org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectSuperclass(ClassScope.java:938)
at org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectTypeHierarchy(ClassScope.java:1095)
at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.connectTypeHierarchy(CompilationUnitScope.java:323)

 

從名字可以看出此異常是內存溢出。之前遇到好多次,解決的方案多是增加Tomcat內存,但效果幾乎都不理想,今天沒有動Tomcat,只是增加了eclipse的內存,此方案出自http://bbs.csdn.net/topics/390961799magi1201網友的留言。

下面是我的解決步驟:

1、先在eclipse安裝目錄中將eclipse的啟動參數調大一些--在eclipse的安裝目錄的ini文件,我用的是STS,所以是STS.ini文件

原文件參數:

-startup
plugins/org.eclipse.equinox.launcher_1.3.100.v20150511-1540.jar --launcher.library plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.300.v20150602-1417 -product org.springsource.sts.ide --launcher.defaultAction openFile --launcher.XXMaxPermSize 256M -vmargs -Dosgi.requiredJavaVersion=1.7 -Xms40m -XX:MaxPermSize=256m -Xverify:none -Dorg.eclipse.swt.browser.IEVersion=10001 -Xmx1200m

調整后的文件參數:

-startup
plugins/org.eclipse.equinox.launcher_1.3.100.v20150511-1540.jar --launcher.library plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.300.v20150602-1417 -product org.springsource.sts.ide --launcher.defaultAction openFile --launcher.XXMaxPermSize 512M -vmargs -Dosgi.requiredJavaVersion=1.7 -Xms40m -XX:MaxPermSize=512m -Xverify:none -Dorg.eclipse.swt.browser.IEVersion=10001 -Xmx1200m

注:紅色字體為修改參數

 

2、然后在eclipse的server欄,找到tomcat選項,打開tomcat的配置

2.1

2.2

2.3

在arguments 標簽框下面的VM Arguments 框后面接上自己的tomcat啟動虛擬機參數就可以了。注:紅色線標注的為新增內容。記得點Apply和OK哦

 

后記:此方法一試就靈,原來本項目的內存只夠登錄,再點擊別的功能均出現此異常,安裝上面的方法進行修改后立即恢復正常。但是最重要的考驗是在運行情況下修改項目--待考驗...

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM