最近我在我的Web应用程序中遇到了这个错误:
java.lang.OutOfMemoryError:PermGen空间
这是在Tomcat 6和JDK 1.6上运行的典型Hibernate/JPA + IceFaces/JSF应用程序.显然,重新部署应用程序几次后就会发生这种情况.
导致它的原因以及可以采取哪些措施来避免它?我该如何解决这个问题?
我已经安装了JDK 8并尝试运行Eclipse.我收到以下警告信息:
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512m;
support was removed in 8.0
Run Code Online (Sandbox Code Playgroud)
忽视这个论点的原因是什么?
我在构建Maven项目时遇到了这个错误,我增加了MAVEN_OPTS,但是我发现了一些类似的帖子,但是他们引用了其他的东西.我该如何解决?
The system is out of resources.
Consult the following stack trace for details.
java.lang.OutOfMemoryError: PermGen space
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at org.codehaus.plexus.compiler.javac.IsolatedClassLoader.loadClass(IsolatedClassLoader.java:56)
at com.sun.tools.javac.comp.Annotate.<init>(Annotate.java:52)
at com.sun.tools.javac.comp.Annotate.instance(Annotate.java:36)
at com.sun.tools.javac.jvm.ClassReader.<init>(ClassReader.java:215)
at com.sun.tools.javac.jvm.ClassReader.instance(ClassReader.java:168)
at com.sun.tools.javac.main.JavaCompiler.<init>(JavaCompiler.java:293)
at com.sun.tools.javac.main.JavaCompiler.instance(JavaCompiler.java:72)
at com.sun.tools.javac.main.Main.compile(Main.java:340)
at com.sun.tools.javac.main.Main.compile(Main.java:279)
at com.sun.tools.javac.main.Main.compile(Main.java:270)
at com.sun.tools.javac.Main.compile(Main.java:87)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess(JavacCompiler.java:420)
at org.codehaus.plexus.compiler.javac.JavacCompiler.compile(JavacCompiler.java:141)
at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:493)
at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:114)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694) …Run Code Online (Sandbox Code Playgroud) 我知道PermGen是什么,它用于什么,它失败的原因,如何增加它等等.
我不知道的是PermGen实际上代表什么.永久......根......什么?
有谁知道PermGen实际上代表什么?
在Java 7之前,JVM内存中有一个名为PermGen的区域,JVM用于保存其类.在Java 8中,它被删除并被称为Metaspace的区域取代.
PermGen和Metaspace之间最重要的区别是什么?
我知道的唯一区别是java.lang.OutOfMemoryError: PermGen space不能再抛出并MaxPermSize忽略VM参数.
我正在使用tomcat 6.0,当我正在编制索引时(而不是在我启动tomcat时),我有一个permgen空间错误.
我怎么能增加那个空间?
谢谢
我有这个带有tomcat,java和grails的VM.我一直在犯permgen错误所以我环顾四周找到了解决方案:
set JAVA_OPTS="-Xms256m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m"
Run Code Online (Sandbox Code Playgroud)
我使用SSH访问vm并输入上面的参数.我想这可以解决问题.事情是,我想确保我做得正确.所以我再次搜索了如何检查当前的permSize,这是我得到的解决方案:
jinfo -flag MaxPermSize 6444
Run Code Online (Sandbox Code Playgroud)
6444是pid,作为回应,我得到了这个.
-XX:MaxPermSize=85983232
Run Code Online (Sandbox Code Playgroud)
问题:maxPermSize的值是以字节为单位的吗?因为,如果是,那就意味着java_opts命令不起作用.我期待得到512米,但85983232字节= 82 MB ...或者我看错了..?有人可以开导我这个吗?d:
我在Windows环境中工作.每次我使用tomcat时都会收到此错误
Apr 30, 2012 5:30:37 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
java.lang.OutOfMemoryError: PermGen space
2012-04-30 17:30:37.719 INFO net.spy.memcached.MemcachedConnection: Connection state changed for sun.nio.ch.SelectionKeyImpl@4ae53a99
2012-04-30 17:30:37.719 INFO net.spy.memcached.MemcachedConnection: Reconnecting due to failure to connect to {QA sa=localhost/127.0.0.1:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0}
java.net.ConnectException: Connection refused: no further information
Apr 30, 2012 5:30:37 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
java.lang.OutOfMemoryError: PermGen space
Exception in thread "Memcached IO over {MemcachedConnection to localhost/127.0.0.1:11211}" java.lang.OutOfMemoryError: …Run Code Online (Sandbox Code Playgroud) 我们遇到了Java.lang.OutOfMemoryError:PermGen空间错误并查看了tomcat JVM参数,除了我们还指定的-Xms和-Xmxparams之外-XX:MaxPermSize=128m.经过一些分析后,我偶尔可以看到PermGen空间上发生的垃圾收集,使其无法完全运行.
我的问题是:除了增加-XX:MaxPermSize我指定的差异之外,还有-XX:PermSize什么呢?我知道总的内存中,然后将XMX + MaxPermSize参数,但是否有其他原因,-XX:PermSize应该不是的时候是有-XX:MaxPermSize规定的?
如果您有处理这些JVM参数的实际经验,请分享.
PS.JVM是HotSpot 64位服务器VM build 16.2-b04
在多个帖子中提到:不当使用ThreadLocal原因内存泄漏.我正在努力了解内存泄漏将如何发生ThreadLocal.
我发现它的唯一情况如下:
Web服务器维护一个线程池(例如,用于servlet).如果
ThreadLocal没有删除变量,那些线程可以创建内存泄漏,因为线程没有死亡.
这种情况没有提到"Perm Space"内存泄漏.这是内存泄漏的唯一(主要)用例吗?
permgen ×10
java ×9
jvm ×3
tomcat ×3
java-8 ×2
memory-leaks ×2
exception ×1
grails ×1
java-6 ×1
java-7 ×1
jvm-hotspot ×1
maven ×1
metaspace ×1
thread-local ×1
tomcat6 ×1