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