Java記憶體管理-Permanent Space

來源:互聯網
上載者:User

VM 的Permanent generation space,實際上就是方法區,儲存了下面兩種類型的資料:

 

1.Class的節本資訊

Package Name
Super class package name
Class or interface
Type modifiers
Super inferface package name

 

2.其它資訊

The constant pool for the type 
Field information 
Method information 
All class (static) variables declared 
in the type, except constants 
A reference to class ClassLoader 
A reference to class Class

 

本來SUN設計的時候認為這個地區在JVM啟動的時候就固定了,但他沒有想到現在動態會用得這麼廣泛。而且這個地區有特殊的垃圾收回機制,現在的問題是動態載入類到這個地區後,gc根本沒辦法回收! 

現在開發中最常見的錯誤莫過於Permgen Space!

解決辦法:

1,把不必要的 jar 檔案清理出 lib;
2,不要頻繁地進行 reload;
3,增加 PermGen Space 記憶體地區,預設是 64MB,可以採用 -XX:MaxPermSize 這個 JVM 參數改這塊地區改大一些,這個參數詳見:
http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp

如果用的是 Tomcat 的話,可以在 catalina.bat 開始處增加一行 set JAVA_OPTS=-XX:MaxPermSize=128m

 

VM 的Permanent generation space,實際上就是方法區,儲存了下面兩種類型的資料:

 

1.Class的節本資訊

Package Name
Super class package name
Class or interface
Type modifiers
Super inferface package name

 

2.其它資訊

The constant pool for the type 
Field information 
Method information 
All class (static) variables declared 
in the type, except constants 
A reference to class ClassLoader 
A reference to class Class

 

本來SUN設計的時候認為這個地區在JVM啟動的時候就固定了,但他沒有想到現在動態會用得這麼廣泛。而且這個地區有特殊的垃圾收回機制,現在的問題是動態載入類到這個地區後,gc根本沒辦法回收! 

現在開發中最常見的錯誤莫過於Permgen Space!

解決辦法:

1,把不必要的 jar 檔案清理出 lib;
2,不要頻繁地進行 reload;
3,增加 PermGen Space 記憶體地區,預設是 64MB,可以採用 -XX:MaxPermSize 這個 JVM 參數改這塊地區改大一些,這個參數詳見:
http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp

如果用的是 Tomcat 的話,可以在 catalina.bat 開始處增加一行 set JAVA_OPTS=-XX:MaxPermSize=128m

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.