Java Runtime Data Area

Java运行时数据区划分

  • Program Counter (程序寄存器 PC) 存放下一条指令位置,线程私有。
  • Stacks (栈) 分为JVM Stacks 和 native method stacks 线程私有
    Fream: 每个方法对应一个栈帧
    1. Local Variable Table 本地变量表
    2. Operand Stack
    3. Dynamic Linking
    4. Return Address a() -> a(),方法a调用了方法b,b方法的返回值放在什么地方。
      Local Variables + Operand Stacks + Dynamic Linking + Return Address = Fream
  • Direct Memory(java1.4以后NIO)JVM可以直接访问的内核空间的内存(OS管理的内存)
  • Method Area It stores per-class structures 线程共享
    Method Area是一个逻辑上的概念:
    1. Perm Space ( < 1.8),字符串常量位于Perm Space,FGC不会清理,大小由启动的时候指定,不能变。
    2. Meta Space(>= 1.8),符串常量位于堆,会触发FGC清理,不设定的话最大就是物理内存。
  • Heap 线程共享
  • Runtime Constant Pool 运行时常量池

which instances are roots?
JVM stack,native method stack,run-time constant pool,static references in method area,Clazz

GC roots包括:
1. 线程栈变量
2. 静态变量
3. 常量池
4. JNI指针

猜你喜欢

转载自blog.csdn.net/hxj413977035/article/details/113655428