JVM IN JAVA

JVM  in Java


The Java Virtual Machine is called JVM, is an abstract computing machine or virtual machine interface that drives the java code.

JVM act as runtime engine to run java based application.

JVM is part of JRE & its responsible to load and run java class file.





Java is called platform independent because of Java Virtual Machine. As different computers with the different operating system have their JVM, when we submit a .class file to any operating system, JVM interprets the bytecode into machine level language.


METHOD AREA -


JVM has a method area common across all the threads. It contains per-class elements like constant pool, fieldsmethod local data, method code, constructor codes etc.  This method area gets created during JVM start-up. it also include static variable.


HEAP AREA -

The heap is created when the JVM starts up . for every jvm one heap area is available.

Object and its corresponding instance variable will be store inside heap area.

in java array is also object .

heap memory is not thread safe.


STACK MEMORY -

Stack space is mainly used for storing order of method execution and local variables. Stack always stored blocks in LIFO.

it contain local variable.



interpreter -

The Java interpreter converts the Java bytecode (.class file) into the code understand by the operating system (machine code) . it read bytecode line by line.


JIT -

 JIT is a part of the JVM that optimizes the performance of the application. JIT stands for Java-In-Time Compiler. The JIT compilation is also known as dynamic compilation.

main purpose is to improve performance.



working of JIT  -


If the JIT compiler environment variable is properly set, the JVM reads the .class file (bytecode) for interpretation after that it passes to the JIT compiler for further process. After getting the bytecode, the JIT compiler transforms it into the native code (machine-readable code).

  • Java Runtime Environment (JRE) provides the Java compiler (javac)to compile the Java source code into the bytecode (.class file). After that, JVM loads the .class file at runtime and transform the bytecode into the binary code (machine code). Further, the machine code is used by the interpreter.
  • We know that the interpretation of Java bytecode reduces the performance of the native application. It is the reason to implement the JIT compiler. The JIT compiler accelerates the performance of the application by compiling the bytecode into native machine code.
  • It is enabled by default when a method is invoked. The JVM directly invokes the compiled code of the method without interpreting it. It does not require much memory usage.

Therefore, the JIT compiler boosts the performance of the native application. 











Comments

Popular posts from this blog

OBJECT ORIENTED CONCEPTS

Arrays programms