1)
Class Loader
2)
Method Area
3)
Heap
4)
Stack
5)
PC Registers
6)
Native Method Stack
7)
Interpreter
8)
JIT
Let’s learn these concepts one by one.
Class Loader: It
will load the class on request.
Method Area: Inside
a Java virtual machine instance, information about loaded types is stored in a
logical area of memory called the method area. When the Java virtual machine
loads a type, it uses a class loader to locate the appropriate class file. The
class loader reads in the class file, a linear stream of binary data and passes
it to the virtual machine. The virtual machine extracts information about the
type from the binary data and stores the information in the method area. Memory
for class (static) variables declared in the class is also taken from the
method area.
Heap: It
is to store java objects. Size of heap is depends on JVM. It can be increase or
decrease by developer also. All objects in heap are accessible by all threads.
Whenever size of heap is full, JVM will throw an exception of
OutofMemoryException.
Stack: It
is to store the Methods and the structure of class like, variables,
constructor, local variables etc. When the stack is full, JVM will throw
StackOverflowException.
PC Registers: It
contains address of JVM activity, which is currently being executed.
Native Method Stack:
It stores all the native methods information.
Interpreter: It
will read the java code and convert into the machine language supported by OS.
JIT: Just
in Time compiles the machine language code into byte code.
Below is the architecture of JVM Memory Allocation.
No comments:
Post a Comment
Thank you for your comments.