开发者

PermGen space in java

What 开发者_运维问答is PermGen-space in Java? Our team has issues with PermGen-space getting increased. This increase affects performance in the end.

I wanted to know about what PermGen-space is and how can we optimize its space usage?


From http://java.sun.com/docs/hotspot/gc1.4.2/faq.html (Questions 7--10)

  1. How should the permanent generation be sized?

    The permanent generation is used to hold reflective of the VM itself such as class objects and method objects. These reflective objects are allocated directly into the permanent generation, and it is sized independently from the other generations. Generally, sizing of this generation can be ignored because the default size is adequate. However, programs that load many classes may need a larger permanent generation.

  2. How can I tell if the permanent generation is filling up?

    Starting in 1.4.2 -XX:+PrintGCDetails will print information about all parts of the heap collected at each garbage collection. For a full collection

    [Full GC [Tenured: 30437K->33739K(280576K), 0.7050569 secs] 106231K->33739K(362112K), [Perm : 2919K->2919K(16384K)], 0.7052334 secs]

    this example shows that little was collected in the permanent generation (it went from 2919K used before the collection to 2919K used after the collection) and the current size of the permanent generation is 16384K.

  3. How can I increase the permanent generation size?

    Use the command line option -XX:MaxPermSize=

  4. How do I know what classes are being loaded or unloaded?

    Use the command line options -XX:+TraceClassloading and -XX:+TraceClassUnloading


In the JVM, PermGen holds the classes that have been loaded/created. This information is garbage collected like the other parts of the heap, however there are rough edges that can prevent this from happening. Just increase PermGen space

Start your JVM with
-XX:MaxPermSize=Xm
where X is a number like 128, 256.

A good link about this error


Basically, Perm generation refers to the space on the heap where all the loaded classes are stored. It's exclusively used to store the class definitions.

Besides the basic fields of a Java class there are

* Methods of a class (including the bytecodes)
* Names of the classes (in the form of an object that points to a string also in the permanent generation)
* Constant pool information (data read from the class file, see chapter 4 of the JVM specification for all the details).
* Object arrays and type arrays associated with a class (e.g., an object array containing references to methods).
* Internal objects created by the JVM (java/lang/Object or java/lang/exception for instance)
* Information used for optimization by the compilers (JITs) 

See here.


I know this is an old thread but I think it is worthy to mention that there is no PermGen space after the introduction of Java 8. The JDK 8 HotSpot JVM uses native memory for the representation of class metadata, similar to the Oracle JRockit and IBM JVM's. The metadata information is not gone, just that the space where it was held is no longer contiguous to the Java heap. The metadata has now moved to native memory to an area known as the “Metaspace”. Since the class metadata is allocated out of native memory, the max available space is the total available system memory.

There is a very nice article about this subject here: https://www.infoq.com/articles/Java-PERMGEN-Removed

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜