JVM之Java运行时数据区浅析---TODO

JVM之运行时数据区 ————– TODO

Wirte by 021.

image-20211111172223120

示例代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

public class PerformanceTest {

final int a = 0;
final int b =10;
final static int c = 0;
volatile int d = 0;
volatile int e = 0;

public static void main(String[] args){

int f = 0;
PerformanceTest p = new PerformanceTest();
p.test(a,b);
System.out.println(VM.current().details());
System.out.println(ClassLayout.parseClass(PerformanceTest.class).toPrintable());

}
private int test(int a , int b){

System.out.println(this.getClass().getClassLoader());
System.out.println(Long.class.getClass().getClassLoader());
System.out.println(Integer.class.getClass().getClassLoader());

return a + b;
}

}

Progarm Counter 程序计数器

  • 执行代码行标记

JVM stack 方法栈

  • Local Variable Table 局部变量表

    1
    2
    3
    4
    args[]

    int f = 0;

  • Operand Stack 操作数栈

    1
      
  • Dynamic Linking 静态连接

    1
    当前线程在运行时与常量池符号的连接. 指向常量池的变量.  示例代码中:final static int c = 0,p.test(0,0);;
  • Retuen Address 返回地址

    1
    函数执行结果的值地址存入栈顶. p.test(a,b) = return a + b;

本地方法栈

  • Native 本地方法相关方法栈.

方法区

  • l

Direct Memory

  • JVM可以直接访问的内核空间内存,0拷贝。

参数设置

1
2
3
默认: -Xmixed 混合模式
-Xint 解释模式,启动块,执行稍微慢
-XComp 编译模式,启动时间慢,需要编译