Java运行时数据区域详解

JVM运行时数据区域(Run-Time Data Areas)包括以下几部分:

Java运行时数据区域详解

1.程序计数器(The PC Register)

2. Java虚拟机栈(Java Virtual Machine Stacks)

每一个JVM线程都有一个Java虚拟机栈,当线程被创建的时候该虚拟机栈就会被一起创建。虚拟机栈描述的是Java方法执行的内存模型:每个方法在执行的同时都会创建一个栈帧(Stack Frame)。每一个方法从调用直至执行完成的过程,就对应着一个栈帧在虚拟机栈中入栈到出栈的过程。栈帧存储的信息包括:

局部变量表(Local Variable Table)

操作数栈(Operand Stack)

动态链接(Dynamic Linking)

方法返回地址(Return Address)

3. Heap

Head用来在运行时分配class和arrays实例。class的实例只会被GC(Garbage Collector)回收。

Heap分为以下几个区域:

Young Generation(年轻代)

Old Generation(老生代)

Permanent Generation(永久代)

4. Method Area

5.运行时常量池(Run-Time Constant Pool)

运行时常量池(Runtime Constant Pool)包括:

numeric literals

string literals

class references

field references

method references

Constant Pool 包含以下的类型:

Integer

A 4 byte int constant

Long

An 8 byte long constant

Float

A 4 byte float constant

Double

A 8 byte double constant

String

A String constant that points at another Utf8 entry in the constant pool which contains the actual bytes

Utf8

A stream of bytes representing a Utf8 encoded sequence of characters

Class

A Class constant that points at another Utf8 entry in the constant pool which contains the fully qualified class name in the internal JVM format (this is used by the dynamic linking process)

NameAndType

A colon separated pair of values each pointing at other entries in the constant pool. The first value (before the colon) points at a Utf8 string entry that is the method or field name. The second value points at a Utf8 entry that represents the type, in the case of a field this is the fully qualified class name, in the case of a method this is a list of fully qualified class names one per parameter.

FieldRef,

MethodRef,

InterfaceMethodRef

A dot separated pair of values each pointing at other entries in the constant pool. The first value (before the dot) points at a Class entry. The second value points at a NameAndType entry.

 6. 本地方法栈(Native Method Stacks)

从Java 8起,Method Area被替换成MetaSpace.

上一篇:[LeetCode] 1037. 有效的回旋镖


下一篇:10:C++搭配PCL对点云去中心化