Where does class, object, reference variable get stored in Java. In heap or in stack? Where is heap or stack located?

Runtime data area in JVM can be divided as below,

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

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

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

  4. 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)

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

Leave a Comment