Java 发表评论

JVM(Java Virtual Machine):在这里插入图片描述

  1. Loading
  2. Linking
  3. Initialization
JVM Memory

Method area :In method area, all class level information like class name, immediate parent class name, methods and variables information etc. are stored, including static variables. There is only one method area per JVM, and it is a shared resource. Key:shared. Only one per JVM

Heap area :Information of all objects is stored in heap area. There is also one Heap Area per JVM. It is also a shared resource. Key:shared. Only one per KVM

Stack area :For every thread, JVM create one run-time stack which is stored here. Every block of this stack is called activation record/stack frame which store methods calls. All local variables of that method are stored in their corresponding frame. After a thread terminate, it’s run-time stack will be destroyed by JVM. It is not a shared resource. Key:Per thread, current thread stack frame. eg. recusively on itself will cause stackOverFlow

PC Registers :Store address of current execution instruction of a thread. Obviously each thread has separate PC Registers.Key:Per thread, current thread next execute

Native method stacks :For every thread, separate native stack is created. It stores native method information Called from stack area.

**Execution Engine**

Execution engine execute the .class (bytecode). It reads the byte-code line by line, use data and information present in various memory area and execute instructions. It can be classified in three parts :-

Interpreter : It interprets the bytecode line by line and then executes. The disadvantage here is that when one method is called multiple times, every time interpretation is required.
Just-In-Time Compiler(JIT) : It is used to increase efficiency of interpreter.It compiles the entire bytecode and changes it to native code so whenever interpreter see repeated method calls,JIT provide direct native code for that part so re-interpretation is not required,thus efficiency is improved.
Garbage Collector : It destroy un-referenced objects.For more on Garbage Collector,refer Garbage Collector.







电子邮件地址不会被公开。 必填项已用*标注

昵称 *