Java的方法名等class文件数据存在哪里,Java8之后的变化

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值