1.

Types of memory areas allocated by JVM

Answer»

JVM stands for Java Virtual Machine. It is the driving force that provides the run time environment. It converts the Java ByteCode into machine code. It is an ABSTRACT machine that provides the specification for execution of a Java program during runtime.

When we compile a .java file, files with nomenclature same to that of the class are created with the extension .class by the Java Compiler. These files contain the byte code. There are various steps involved when a .class file is executed. These steps provide a detailed account of the Java Virtual Machine.

There are typically 6 types of memory areas ALLOCATED in JVM.

  • CLASSLOADER: Classloader is a subsystem of JVM and a part of the Java Runtime Environment which dynamically loads class in the JVM.
  • Method Area: Method Area is common across all threads. It consists of per-class elements such as constant pool, FIELDS, method data and code and constructor codes. This area gets created during the JVM start-up. If the memory isn’t sufficient then it gives an OutOfMemoryError.
  • Heap: Variables ASSIGNED with this memory structure can be administered during runtime. This leads to dynamic memory allocation.
  • Stack: If the amount of memory required is known beforehand, memory is allocated using stacks.
  • Program Counter Register: It contains the address of the Java virtual machine instruction currently being executed. Programs are a set of instructions given to a computer for performing few specific tasks. The Program Counter Register carries the address of the forthcoming instructions.
  • Native Method Stack: It is a collection of all the native methods used in the application.


Discussion

No Comment Found