Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
532 views
in Technique[技术] by (71.8m points)

eclipse - java.lang.OutOfMemoryError: PermGen space Exception

I am getting this java.lang.OutOfMemoryError: PermGen space Exception. I am using Eclipse Juno and Tomcat 7.0. This Exception occurs at least once in every 10-15 Minutes in a console. 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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

What is java.lang.OutOfMemoryError: PermGen space?

Ans:

The java.lang.OutOfMemoryError: PermGen space message indicates that the Permanent Generation’s area in memory is exhausted.

Any Java applications is allowed to use a limited amount of memory. 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: enter image description here

What will be the solution for this error PermGen space?

Ans:

For Heap,

export JVM_ARGS="-Xms1024m -Xmx1024m" 

For 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; similar to the Oracle JRockit and 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.

Related Link:

  1. https://plumbr.eu/outofmemoryerror/java-heap-space
  2. https://plumbr.eu/outofmemoryerror/permgen-space
  3. http://stas-blogspot.blogspot.in/2011/07/most-complete-list-of-xx-options-for.html#UseConcMarkSweepGC
  4. https://www.javacodegeeks.com/2013/12/decoding-java-lang-outofmemoryerror-permgen-space.html
  5. http://www.javavillage.in/reasons-outofmemory-permespace.php
  6. Dealing with "java.lang.OutOfMemoryError: PermGen space" error

Java 8 Links

  1. What is the use of MetaSpace in Java 8?
  2. https://blogs.oracle.com/poonam/entry/about_g1_garbage_collector_permanent
  3. https://plumbr.eu/outofmemoryerror/metaspace
  4. https://dzone.com/articles/java-8-permgen-metaspace

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...