0
点赞
收藏
分享

微信扫一扫

java堆与方法区、运行时常量池的关系

援引在《The Java Virtual Machine Specification Java SE 14 Edition》中描述

对堆得描述

The Java Virtual Machine has a heap that is shared among all Java Virtual Machine threads. The heap is the run-time data area from which memory for all class instances and arrays is allocated.

简单翻译就是:堆所有Java线程共享的,是用来分配所有类实例和数组的内存的运行时数据区域。 
java堆与方法区、运行时常量池的关系_常量池

 

对方法区的描述


The Java Virtual Machine has a method area

that is shared among all Java Virtual Machine threads. 方法区也是共享的 很重要的一句是


Although the method area  is logically part of the heap, simple implementations may choose not to either  garbage collect or compact it.


这里说到, the method area  is logically part of the heap,方法区是堆的逻辑组成部分 java堆与方法区、运行时常量池的关系_java_02


 



对运行时常量池的描述


A run-time constant pool is a per-class or per-interface run-time representation  of the constant_pool table in a class file (§4.4).

下面一段

Each run-time constant pool is allocated from the Java Virtual Machine's method area (§2.5.4).

 

这里描述到每一个运行时常量池都从java虚拟机的方法区分配而来。

java堆与方法区、运行时常量池的关系_开发语言_03

 

 综上分析,堆、方法区与运行时常量池的关系如下

java堆与方法区、运行时常量池的关系_方法区_04

 


举报

相关推荐

0 条评论