[英]java.lang.OutOfMemoryError: PermGen space Exception
I am getting this java.lang.OutOfMemoryError: PermGen space
Exception.我收到这个
java.lang.OutOfMemoryError: PermGen space
Exception。 I am using Eclipse Juno and Tomcat 7.0.我正在使用 Eclipse Juno 和 Tomcat 7.0。 This Exception occurs at least once in every 10-15 Minutes in a console.
此异常在控制台中每 10-15 分钟至少发生一次。 How to resolve it?
如何解决?
Feb 25, 2016 10:23:23 AM org.springframework.beans.factory.support.DefaultListableBeanFactory destroyBean
SEVERE: Destroy method on bean with name 'mvcUrlPathHelper' threw an exception
java.lang.OutOfMemoryError: PermGen space
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2895)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2895)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessBeforeDestruction(PersistenceAnnotationBeanPostProcessor.java:375)
at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:242)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:925)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:932)
at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:997)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:547)
Feb 25, 2016 10:23:24 AM org.springframework.beans.factory.support.DefaultListableBeanFactory destroyBean
SEVERE: Destroy method on bean with name 'mvcPathMatcher' threw an exception
java.lang.OutOfMemoryError: PermGen space
Exception in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]" java.lang.OutOfMemoryError: PermGen space
What is java.lang.OutOfMemoryError: PermGen space?什么是 java.lang.OutOfMemoryError: PermGen space?
Ans:答:
The java.lang.OutOfMemoryError: PermGen space
message indicates that the Permanent Generation's area in memory is exhausted. java.lang.OutOfMemoryError: PermGen space
消息表明永久代在内存中的区域已用完。
Any Java applications is allowed to use a limited amount of memory.任何 Java 应用程序都可以使用有限的内存量。 The exact amount of memory your particular application can use is specified during application startup.
您的特定应用程序可以使用的确切内存量是在应用程序启动期间指定的。
Java memory is separated into different regions which can be seen in the following image: Java 内存被分成不同的区域,如下图所示:
What will be the solution for this error PermGen space?这个错误永久代空间的解决方案是什么?
Ans:答:
For Heap,对于堆,
export JVM_ARGS="-Xms1024m -Xmx1024m"
For Permgen,对于 Permgen,
JVM_ARGS="-XX:PermSize=512M -XX:MaxPermSize=512m"
You can give also additional section您还可以提供额外的部分
-XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC XX:+CMSClassUnloadingEnabled
You can also give more additional section :)您还可以提供更多附加部分:)
-XX:PermSize=512m -XX:MaxPermSize=512m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -XX:SurvivorRatio=2 -XX:MaxTenuringThreshold=128 -XX:TargetSurvivorRatio=90 -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+CMSIncrementalPacing -XX:CMSIncrementalDutyCycleMin=0 -XX:CMSIncrementalDutyCycle=10 -XX:+UseTLAB -XX:+CMSParallelRemarkEnabled -XX:+CMSClassUnloadingEnabled
Metaspace: A new memory space is born元空间:一个新的内存空间诞生
The JDK 8 HotSpot JVM
is now using native memory for the representation of class metadata and is called Metaspace
; JDK 8 HotSpot JVM
现在使用本机内存来表示类元数据,称为Metaspace
; similar to the Oracle JRockit
and IBM JVM's
.类似于 Oracle
JRockit
和 IBM JVM's
.
The good news is that it means no more java.lang.OutOfMemoryError: PermGen space
problems and no need for you to tune and monitor this memory space anymore.好消息是,这意味着不再有
java.lang.OutOfMemoryError: PermGen space
问题,并且您不再需要调整和监视此内存空间。
Related Link:相关链接:
Java 8 Links Java 8 链接
It is easy to configure Java for more PermGenSpace but I would recommend to migrate to Java 1.8 runtime instead.为更多 PermGenSpace 配置 Java 很容易,但我建议改为迁移到 Java 1.8 运行时。 Install Java 8 SDK and add two lines like
安装 Java 8 SDK 并添加两行,如
-vm
D:/jdk8/jre/bin/javaw.exe
to eclipse.ini.到 eclipse.ini。 This problem is fixed starting from Java 1.8 and does not longer require any hacks.
从 Java 1.8 开始,此问题已修复,不再需要任何 hack。
When you get java.lang.OutOfMemoryError: PermGen space errors
, you need to increase the permanent generation space available to Eclipse.To Do this please modify your eclipse.ini
file of Eclipse.当您收到
java.lang.OutOfMemoryError: PermGen space errors
,您需要增加 Eclipse 可用的永久代空间。为此,请修改 Eclipse 的eclipse.ini
文件。 set the as below设置如下
-XX:MaxPermSize=1024m
For more help you can refer the below link,如需更多帮助,您可以参考以下链接,
java.lang.OutOfMemoryError: PermGen space java.lang.OutOfMemoryError: PermGen 空间
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.