2010-01-19 65 views
2

什麼是PermGen空間Java?我們的團隊遇到問題PermGen-space正在增加。這種增加最終會影響性能。java中的PermGen空間

我想知道什麼PermGen空間是,我們如何優化其空間使用率?

+4

你試過Google嗎? – 2010-01-19 09:19:45

+1

我搜索,但其中大部分是關於outofmemory上下文。所以我只想知道在自己的情況下只有PermGen – GuruKulki 2010-01-19 09:21:47

+0

http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html是一個很好的資源。 – 2010-01-19 09:27:02

回答

9

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

  • 應如何永久代會大小?

    永久生成器用於保存虛擬機本身的反射,例如類對象和方法對象。這些反射物體被直接分配到永久世代中,並且其大小與其他世代獨立。一般來說,這一代的大小可以忽略,因爲默認大小是足夠的。但是,加載許多類的程序可能需要更大的永久代。

  • 我如何判斷永久代是否填滿?

    從1.4.2開始-XX:+ PrintGCDetails將打印每個垃圾回收收集堆的所有部分的信息。對於一個完整的集合

    [全GC [終身:30437K-> 33739K(280576K),0.7050569秒] 106231K-> 33739K(362112K),[彼爾姆:2919K-> 2919K(16384K)],0.7052334秒]

    這個例子顯示,在永久代中收集的很少(從收集之前使用的2919K變爲收集後使用的2919K),永久代的當前規模爲16384K。

  • 我該如何增加永久代的大小?

    使用命令行選項-XX:MaxPermSize參數=

  • 我怎麼知道類裝載什麼或卸載?

    使用命令行選項-XX:+ TraceClassloading和-XX:+ TraceClassUnloading

  • 2

    在JVM中,PermGen擁有已加載/創建的類。這些信息是垃圾收集的,就像堆的其他部分一樣,但是有粗糙的邊緣可以防止這種情況發生。只是增加PermGen的空間

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

    一個好的link有關此錯誤

    +0

    這不是關於類的元數據,而是實際的類。 :-) – wds 2010-01-19 09:29:36

    1

    基本上,彼爾姆代是指在其中所有裝入的類被存儲在堆的空間。它專門用於存儲類定義。

    另外一個Java類的基本領域有

    * 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這裏。

    相關問題