logo CBCE Skill INDIA

Welcome to CBCE Skill INDIA. An ISO 9001:2015 Certified Autonomous Body | Best Quality Computer and Skills Training Provider Organization. Established Under Indian Trust Act 1882, Govt. of India. Identity No. - IV-190200628, and registered under NITI Aayog Govt. of India. Identity No. - WB/2023/0344555. Also registered under Ministry of Micro, Small & Medium Enterprises - MSME (Govt. of India). Registration Number - UDYAM-WB-06-0031863

How many Types of Memory Areas are Allocated by JVM?


How many Types of Memory Areas are Allocated by JVM

The JVM allocates memory into several different areas, each serving a specific purpose in managing Java applications. The main memory areas allocated by the JVM are as follows:

 

  1. Heap Memory:

    • The heap memory is the runtime data area where Java objects are allocated. It's shared among all threads in the JVM.
    • The heap is divided into two main regions: the Young Generation and the Old Generation.
      • Young Generation: It consists of the Eden space and two Survivor spaces (S0 and S1). New objects are initially allocated in the Eden space, and after surviving a garbage collection, they are moved to one of the Survivor spaces.
      • Old Generation (Tenured Generation): It stores long-lived objects that have survived multiple garbage collection cycles in the Young Generation.
  2. Method Area (PermGen/Metaspace):

    • The method area, also known as Permanent Generation (PermGen) in older JVM versions or Metaspace in newer versions, stores class metadata, method information, static variables, and other static data.
    • In older JVM versions (prior to Java 8), PermGen had a fixed maximum size allocated by the JVM.
    • In Java 8 and later versions, PermGen was replaced by Metaspace, which dynamically adjusts its size based on the application's memory requirements.
  3. Runtime Constant Pool:

    • The runtime constant pool is a part of the method area that stores constant variables, method, and class references used by the Java bytecode instructions.
    • It includes symbolic references to classes, fields, and methods, as well as the actual constants used in the code.
  4. Native Method Stacks:

    • Each thread in the JVM has its own native method stack, which stores native method information and data.
    • These stacks are used for invoking native methods, which are implemented in languages like C or C++ and accessed through the Java Native Interface (JNI).
  5. Java Stacks:

    • Each thread in the JVM also has its own Java stack, which stores method invocation records and local variables.
    • Java stacks are used for executing Java methods, including handling method invocations, parameters, and local variables.
  6. PC Registers:

    • Each Java thread has its own Program Counter (PC) register, which stores the address of the currently executing JVM instruction.
    • PC registers are used to support thread execution and context switching.

 

These memory areas work together to manage the execution of Java programs within the JVM, providing the necessary resources for storing objects, executing methods, and managing thread execution.

 

Thank you,

Popular Post:

Give us your feedback!

Your email address will not be published. Required fields are marked *
0 Comments Write Comment