JVM Architecture

preview_player
Показать описание
ATTENTION DATA SCIENCE ASPIRANTS:
Click Below Link to Download Proven 90-Day Roadmap to become a Data Scientist in 90 days

This video explains about the internals of the JVM architecture. In this video, I am going to explain about the 3 major components of JVM architecture,
Class Loader, runtime data area, and execution engine.

class loader is the first main component in JVM architecture, which has 3 phases loading, linking, and initialization. First let’s look at the loading phase of class loader component. In the loading phase, we have 3 types of class loaders.

Second main component in JVM architecture is the run time data area. Just like how a car needs a road, or how a train needs a railway track to run, similarly JVM needs memory area to store the class files and execute them.
There are 5 types of memory data area. They are method area, Heap memory, Stack memory, PC Registers, and Native method stacks

Method area- all the class level data are stored in this memory area. For example, class level static variables are stored in this memory area.

Heap memory – all the objects and instance variables are stored in this memory area.

Stack memory – this contains three sections of memory areas.
Local variable – memory area that stores all the local variables that is used within a method
Operand stack – contains all the operands that are used within a method.
Frame data – this contains any catch block information, in case any exception occurs within method.

PC registers – this memory area holds the current executing instructions

Native method stacks – memory area which holds the native method information

The 3rd main component in JVM architecture is the execution engine. This is the actual engine that converts the bytecode to machine code and executes the instructions. This contains Interpreter, JIT compiler, Garbage collector, and Java Native method interface.

Interpreter – Interpreter is the one that reads the class files or bytecode and executes it one by one. The problem with the interpreter is that, when a method is called multiple times, it interprets those lines of bytecode again and again.

JIT compiler – JIT compiler helps in overcoming the problem of the interpreter. When repeated method calls occur, JIT compiler compiles the bytecode to native code. This native code will be used directly for repeated method calls. JIT compiler contains few components to achieve this feature
Intermediate code generator – generates intermediate code
Code optimizer – optimizes the intermediate code for better performance
Target code generator – converts intermediate code to native machine code
Profiler – it is responsible for finding the hotspots, methods which are called repeatedly.
Garbage collector – Garbage collector is responsible for destroying the objects that are no longer used.
Java native method interface – It is responsible for interacting with native libraries and makes it available for the JVM execution engine.
In this video, we saw that the JVM architecture has 3 main components namely class loader, run time data area, and execution engine.
Class loader in turn has 3 subsystems, which are loading phase, linking phase, and initialization phase.
Second main component is the Runtime data area, which has 5 memory areas namely method area, heap memory, stack memory, PC registers and JNI.
The 3rd main component is the execution engine. This contains some components like interpreter, JIT compiler, JNI, and Garbage collector.
In the next video, we will look at the “Class structure and components”
Рекомендации по теме
Комментарии
Автор



1)Class Loader
2)Runtime Data area
3)Execution Engine

1) Class Loader
ClassLoader has three phases
Phase-1 =>(Loading)


...1) Bootstrap ClassLoader
It loads preCompiled preTrusted System class files to runtime memory area.Files from RT.jar in the jre directory under java installation.

...2)Extension ClassLoader
it loads preCompiled classes from jre/lib/ext directory, when you use third party jar files in your project, they are added into extension folder by the
extensionClassLoader. So extension ClassLoader makes these preCompiled classes available to the JVM by loading the files to the memory area.
...3)Application ClassLoader
Its role is to load your compiled classes to the memory the program you wrote.


Phase-2 (Linking)

Verify : in this part of linking all the class file loaded into the memory by classLoaders in the form of byteCode are verified if the conform to the standards.
Prepare: In this part of linking memory is allocated the static variables are default values are assigned.
Resolve: In this part of linking all the symbolic references are replaced with actual references.


Phase-3) Initialization
In this part all the static variables are assigned with there actual values and also executes the static initializer at this point of time.



2) RunTime Data Area
JVM needs memory area to store the class files and execute them.
Five types of memory data area.
1) Method area:
In this part class level data is stored. e.g -> All the static variables of the class will be stored in the part of jvm memory.
2) Heap memory:
All the objects and instance variables are stored in this memory ares.
3) Stack Memory
This contain three sections of memory area
-> Local variable:stores all the local variables that are used in a module.
->Operand stack:Contain all the operands that are used in a stack.
->Frame data : This part of memory area contain the catch exception block information in case any exception occur in the method.

4) PC Register :
This memory area holds the current executing instructions.

5) Native method stack:
Memory area that holds the native method information.



3) JVM EXECUTION ENGINE:
This engine converts the bytecode to machine code and executes the instructions.

1) Interpreter :
Reads the classFiles(ByteCode) and executes it one by one. Flaw of Interpreter is when a method is called multiple times it interprets those lines of code again and again.


2) JIT compiler:
JIT compiler compiler to byteCode to native code, it solves the flaw in interpreter. Native code will be used directly for repeated method calls.It has few components
->intermediate code generator = generate intermediate code.
->Code optimizer = optimizes the code for better performance.
->Target code generator:converts intermediate code to native code,
->Profiler->responsible for finding hotspots , means methods that are called repeatedly.


3) Garbage Collector: To destory objects that are no longer used.

4) jvm native method interface: responsible for interacting with native libraries and makes it available for JVM execution engine.



sikandermehmood
Автор

I learned a lot than I expected. Thank you sir!

tamaghnadey
Автор

It's simple and solid and crisp... very well organised tutorial on JVM architecture

aniruddhasardar
Автор

Very informative and very basic video. All other videos are just telling about coding without clearing the concept of how programming Languages work. Many many thanks to BigDataElearning.

mushfiqfuad
Автор

Wow, that was an amazing explanation, I have seen many courses and tutorials and I can say that this is the first one where I truly learned this concepts.

alexisarcegomez
Автор

This this truely the best explanation..❤ I have heard that bootstrap class loader starts the other two class loaders.Can you explain it for me?

domvowd
Автор

Thankyou for the detailed explanation 🙂

sowmyaks
Автор

great presentation and excellent explanation

shubhampawar.
Автор

That’s Java
I spent 7 years engaging with the technology and still haven’t got enough it’s ecosystems!

xplorer
Автор

Hi, I learned a lot. And I have confusion, can you tell me which software do you use to make this animation ? thank you.

raysun
Автор

very helpful video thank you so much
i have a question, is there any way to know all classes loaded in the method area section?

ahmedmohammed
Автор

Hi, great explanations. I have a question, where are static final instance variables and final method local variables are stored?

ThePomelo
Автор

At ~2:02, you call it "RTE.jar" and also, hasn't RT.jar started to go away in the most recent JDK versions? Great video tho.

jvsnyc
Автор

what is symbolic reference and actual reference?

blackoutsangli
Автор

Has anyone pointed out that the word "extension" is spelled incorrectly?

BillBennettTV
Автор

finnaly found someone with coherent english grammar to teach me java :))

TheBytaomao
Автор

Does anybody know which programming language is written the JVM in?

harodrone
Автор

That's a lot of information to get in 497 seconds....

swarnalatha-upgi
Автор

This video is great but outdated, in Java8+ there is no method area.

MrGargmay