JVM Memory Structure

The memory structure in the Java is divided into five different parts

Method area
All class level information like class name, are stored, including static variables.

Heap
The Java objects are created in this area. 

Java Stack
While running methods the results are stored in the stack memory. 

PC Registers
Stores the address of current execution instruction of a thread.

Native method stacks
 Similar to Java stack, native methods are executed on the Native method stacks.

JVM Memory Structure

Example


public class Example {

    static int MIN_VALUE = 10;

    

    public static void main() {

       int tmpc = 123;

       int sum = MIN_VALUE + tmpc;

       System.out.println(sum)

}


public class Example {

    static int MIN_VALUE = 10;

     public static void main() {

       int tmpc = 123;

       int sum = MIN_VALUE + tmpc;

       String name = new String("myName");

       System.out.println(sum)

}

MIN_VALUE , main

 

name

tmpc

sum

MIN_VALUE + tmpc

native methods

pointer to the current instruction 

Made with Slides.com