Java Virtual Machine (JVM) Architecture.
0
Java Virtual Machine (JVM) Architecture:
Definition of JVM:
Virtual Machine:
How can we start JVM process?
By using “java” tool.
The java launcher, java, initiates the Java virtual machine instance.
Types of JVMs:
The java 2 SDK, Standard Edition, contains two implementations of the Java virtual machines.
1. Java HotSpot Client VM.
2. Java HotSpot Server VM.
1.Java HotSpot Client VM:
Explanation on Runtime Areas:
2. Heap Area.
3. Java Stack Area.
4. Program counter registers Area.
5. Native Methods Stacks area.
1. Method Area:
4. Program Counter Registers Area:
Definition of JVM:
Virtual Machine:
In general terms VM is a SW that creates an environment between the computer platform and end user in which end user can operate programs.
Original meaning for VM:
As per its functionality is creation of number of different identical execution environments on a single computer to executer programs is called VM.
Java Virtual Machine:
It is also a VM that runs Java bytecode by creating five identical runtime areas to execute class members. This bytecode is generated by java compiler in a JVM understandable format.
How can we start JVM process?
By using “java” tool.
The java launcher, java, initiates the Java virtual machine instance.
Types of JVMs:
The java 2 SDK, Standard Edition, contains two implementations of the Java virtual machines.
1. Java HotSpot Client VM.
2. Java HotSpot Server VM.
1.Java HotSpot Client VM:
The Java HotSpot Client VM is the default virtual machine of the Java 2 SDK and Java 2 Runtime Environment. As its name implies, it is tuned for best performance when running applications in a client environment by reducing application start-up time and memory footprint.
2. Java HotSpot Server VM:
The Java HotSpot Server VM is designed for maximum program execution speed for applications running in a server environment. The Java HotSpot Server VM is invoked by using the –server command-line option when launching an application, as in
Java –server MyApp
Some of the features Java HotSpot technology, common to both VM implementations, are the following.
Adaptive compiler:- Applications are launched using a standard interpreter, but the code is then analyzed as it runs to detect performance bottlenecks, or “hot spots”.
- The Java HotSpot VMs compile those performance-critical portions of the code for a boost in performance, while avoiding unnecessary compilation of seldom-used code(most of the program).
- The Java HotSpot VMs also uses the adaptive compiler to decide, on the fly, how best to optimize compiled code with techniques such as in-lining.
- The runtime analysis performed by the compiler allows it to eliminate guesswork in determining which optimizations will yield the largest performance benefit.
- Java HotSpot technology provides for rapid memory allocation for objects, and it has a fast, efficient, state-of-the-art garbage collector.
- The Java programming language allows for use of multiple, concurrent paths of program execution (called “threada”).
- Java HotSpot technology provides a thread-handling capability that is designed to scale readily for use in large, shared-memory multiprocessor servers.
Whenever we execute a class by specifying its corresponding class name by using the command “java <ClassName>”, the Java launcher, Java, immediately initiates the Java Runtime environment for the class execution as a layer on top of OS, and further the entire setup is divided in to % java Runtime Areas named as
1. Method Area.2. Heap Area.
3. Java Stack Area.
4. Program counter registers Area.
5. Native Methods Stacks area.
- All classes bytecode is loaded and stored in this runtime area, and all static variables are created in this runtime area.
- It is the main memory of JVM. All objects of classes – non-static variables memory are created in this runtime area. This runtime area memory is a finite memory.
- This area can be configured at the time of setting up of runtime environment using non standard option like
- The area can be expandable by its own, depending on the objects creation.
- Method area and Heap area both are sharable memory areas.
- In this runtime area all Java methods are executed.
- In this runtime JVM by default creates two threads, they are
- Main thread.
- Garbage collector thread.
- Main thread is responsible to execute Java methods stats with main method, also responsible to create objects in heap area if it finds “new” keyword in any method logic.
- Garbage collector thread is responsible to destroy all unused objects from heap area.
- For each method execution JVM creates separate block in main thread. Technically this block is called Stack Frame. This stack frame is created when method is called and is destroyed after method execution.
Note: Java operations are called “stack based operations (sequential)”, because every method is executed only in stack.
4. Program Counter Registers Area:
- In this runtime area, a separate program counter register is created for every thread for tracking that thread execution by storing its instruction address.
- In Native Methods stack area, all Java native methods are executed.
0 comments: