援引在《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线程共享的,是用来分配所有类实例和数组的内存的运行时数据区域。
对方法区的描述 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,方法区是堆的逻辑组成部分
对运行时常量池的描述
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虚拟机的方法区分配而来。
综上分析,堆、方法区与运行时常量池的关系如下
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)