JVM内存模型
2020-04-17 00:14:38 0 举报
JVM内存模型大致概图
作者其他创作
大纲/内容
执行具体指令时候 需要用到的内存空间javap 得到字节码指令。
操作栈
新生代
JVM虚拟机
方法出口(用于跳回main方法指定位置)
Eden(8/10)
线程2栈(具体参照线程1)
compute()栈帧
类加载系统
java源码public class Math { public int compute() { int a = 1; int b = 2; int c = (a + b) * 10; return c; } public static void main(String[] args) { Math math = new Math(); int result = math.compute(); System.out.println(result); } }
方法区(元空间)
math.class
运行时数据区(内存模型)
程序计数器
堆(Heap)
存储static,final修饰数据以及类class数据
a = 1b = 2c = 30
javap得到的字节码 public int compute(); Code: 0: iconst_1 1: istore_1 2: iconst_2 3: istore_2 4: iload_1 5: iload_2 6: iadd 7: bipush 10 9: imul 10: istore_3 11: iload_3 12: ireturn
线程1
动态链接
备注:紫色的内存都是线程隔离的,黄色的线程共享
math
线程1栈(FILO)
堆模型
Survivor
main有mymath对象实例存在堆上
to(1/10)
age+1
字节码执行引擎
程序计数器 = 5
老年代 old(2/3)
局部变量表
java MyMath.class
from(1/10)
本地方法栈
main()栈帧
程序调用其他语言实现的方法的时候,用到的内存空间
栈(Stack)
0 条评论
下一页