Context
QQ上的發文,然後就一頓檢索
Java8之前
變量名是存在heap中
- 變量名存在class文件的的 constant pool(常量池)
- class file被load *** 一堆操作,存儲在jvm的runtime-constant-pool(運行時常量池)
- 運行時常量池屬於method area(運行時常量池)
- method area屬於heap中的Perm Gen(永久代)
Oracle資料參數
Oracle
在Perm Gen上的不足
- 因Perm Gen是 固定最大值(最大值可調整)
- 加載過多會OOM
- 當然內存泄漏 導致無法被回收也會
Java8
採用Metaspace來代替Perm Gen,
文章
**大小是運行時調節的
參數設置
To increase PermGen, we have the following commands:
``
-XX:PermSize=N – sets the initial (and minimum size) of the Permanent Generation space
-XX:MaxPermSize=N – sets the maximum size of the Permanent Generation space
``
In Java 8 and onwards, we can set the initial and maximum size of Metaspace using the following commands:
-XX:MetaspaceSize=N – sets the initial (and minimum size) of the Metaspace
-XX:MaxMetaspaceSize=N – sets the maximum size of the Metaspace