class,object,reference变量在哪里存储在java中。在堆或堆栈?堆或堆栈在哪里? [英] Where does class, object, reference variable get stored in java. IN heap or stack? Where is heap or stack located?

查看:165
本文介绍了class,object,reference变量在哪里存储在java中。在堆或堆栈?堆或堆栈在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我理解方法的变量存储在堆栈中,类变量存储在堆中。那么我们创建的类,对象在哪里存储在java中

I understand that variables of a method are stored in stack and class variables are stored in heap. Then where does the class, objects we create get stored in java

推荐答案

JVM中的运行时数据区域可以分为如下,

Runtime data area in JVM can be divided as below,


  1. 方法区域:已编译类文件的存储区域。 (每个JVM实例一个)

  1. Method Area : Storage area for compiled class files. (One per JVM instance)

堆:对象的存储区域。 (每个JVM实例一个)

Heap : Storage area for Objects. (One per JVM instance)

Java堆栈:局部变量的存储区域,中间操作的结果。 (每个线程一个)

Java stack: Storage area for local variables, results of intermediate operations. (One per thread)

PC寄存器:如果下一条指令是本机方法,则存储下一条要执行的指令的地址那么pc寄存器中的值将是未定义的。 (每个线程一个)

PC Register : Stores the address of the next instruction to be executed if the next instruction is native method then the value in pc register will be undefined. (One per thread)

本机方法堆栈:帮助执行本机方法(用Java以外的语言编写的方法)。 (每个线程一个)

Native method stacks : Helps in executing native methods (methods written in languages other than Java). (One per thread)

这篇关于class,object,reference变量在哪里存储在java中。在堆或堆栈?堆或堆栈在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆