How many types of memory areas are allocated by JVM?

There are six main types of memory areas that are allocated by JVM:

  1. Class Loader: Classloader is a subsystem of JVM which is used to load class files. Whenever we run the java program, it is loaded first by the classloader. There are three built-in classloaders in Java: Bootstrap, Extension and System/Application.
  2. Class (Method) Area: Class Area stores per-class structures such as the runtime constant pool, field, method data, and the code for methods.
  3. Heap: It is the runtime data area in which the memory is allocated to the objects.
  4. Stack: Java Stack stores frames. It holds local variables and partial results, and plays a part in method invocation and return. Each thread has a private JVM stack, created at the same time as the thread. A new frame is created each time a method is invoked. A frame is destroyed when its method invocation completes.
  5. Program Counter Register: PC (program counter) register contains the address of the Java virtual machine instruction currently being executed.
  6. Native Method Stack: It contains all the native methods used in the application.

Comments