运行时数据区域---jvms8

Java虚拟机定义了在程序执行期间使用的各种运行时数据区域。 其中一些数据区域是在Java虚拟机启动时创建的,仅在Java虚拟机退出时才被销毁。 其他数据区域是每个线程私有的。线程私有的数据区域在一个线程被创建时创建,在线程关闭时销毁。

一、The pc Register

The Java Virtual Machine can support many threads of execution at once (JLS §17). Each Java Virtual Machine thread has its own pc (program counter) register.

二、Java Virtual Machine Stacks

Each Java Virtual Machine thread has a private Java Virtual Machine stack, created at the same time as the thread. A Java Virtual Machine stack stores frames (A frame is used to store data and partial results, as well as to perform dynamic linking, return values for methods, and dispatch exceptions.).

三、Heap

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.

四、Method Area

The Java Virtual Machine has a method area that is shared among all Java Virtual Machine threads. The method area is analogous to the storage area for compiled code of a conventional language or analogous to the "text" segment in an operating system process. It stores per-class structures such as the run-time constant pool, field and method data, and the code for methods and constructors, including the special methods (

At the level of the Java Virtual Machine, every constructor written in the Java programming language (JLS §8.8) appears as an instance initialization method
that has the special name <init>.

) used in class and instance initialization and interface
initialization.

五、Run-Time Constant Pool  (Each run-time constant pool is allocated from the Java Virtual Machine's method area.)

A run-time constant pool is a per-class or per-interface run-time representation of the constant_pool table in a class file . It contains several kinds of constants, ranging from numeric literals known at compile-time to method and field references that must be resolved at run-time. The run-time constant pool serves a function similar to that of a symbol table for a conventional programming language,
although it contains a wider range of data than a typical symbol table.

六、Native Method Stacks

An implementation of the Java Virtual Machine may use conventional stacks, colloquially called "C stacks," to support native methods (methods written in a
language other than the Java programming language).

 ---------------------------摘自java虚拟机规范1.8版

posted @ 2020-09-06 19:32  kylinmac  阅读(174)  评论(0)    收藏  举报