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