How JVM works in Java

1. Class Loader Subsystem

Java’s dynamic class loads, links and initializes the class when it refers to a class for the first time at runtime, not at compile-time. It performs three major functionality such as Loading, Linking, and Initialization.

1.1 Loading

BootStrap ClassLoader

Extension ClassLoader

Application ClassLoader

1.2 Linking

Verify Prepare Resolve

1.3 Initialization

This is the final phase of Class Loading, here all static variable will be assigned with the original values and static block will be executed.

2. Runtime Data Area

? 1.Method Area – All the Class level data will be stored here including static variables. Method Area is one per JVM and it is a shared resource.

? 2. Heap Area – All the Objects and its corresponding instance variables and arrays will be stored here. Heap Area is also one per JVM since Method area and Heap area shares memory for multiple threads the data stored is not thread safe.

? 3.Stack Area – For every thread, a separate runtime stack will be created. For every method call, one entry will be made in the stack memory which is called as Stack Frame. All local variables will be created in the stack memory. Stack area is thread safe since it is not a shared resource. Stack Frame is divided into three sub-entities such as

? ? 4.Local Variable Array – Related to the method how many local variables are involved and the corresponding values will be stored here.

? ? 5.Operand stack – If any intermediate operation is required to perform, operand stack act as runtime workspace to perform the operation.

? ? 6.Frame data – All symbols corresponding to the method is stored here. In the case of any exception, the catch block information will be maintained in the frame data.

? ? ? 7.PC Registers – Each thread will have separate PC Registers, to hold address of current executing instruction once the instruction is executed the PC register will be updated with the next instruction

? ? ? 8.Native Method stacks – Native Method Stack holds native method information. For every thread, separate native method stack will be created.

3. Execution Engine

1.Interpreter

2.JIT Compiler

? ? 1)Intermediate Code generator – produces intermediate code

? ? 2)Code Optimizer – Code Optimizer is responsible for optimizing the intermediate code generated above

? ? ? 3)Target Code Generator – Target Code Generator is responsible for Generating Machine Code/ Native Code

Profiler – Profiler is a special component, it is responsible for finding the hotspots (i.e) Used to identify whether the method is called multiple time or not.

3.Garbage Collector

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • 年末遭遇各種不順利,在床上躺了兩天之后決定換一種方式消化悲傷。恰逢各種節日,為求一個解脫,選擇背包游蕩。一...
    楚慈Human閱讀 243評論 0 3
  • 玩游戲和做事的思維方式是否互相呼應? 我發現每次玩游戲,都很容易把自己束縛在一個空間內。只玩自己熟悉的東西,很多操...
    圓柱體閱讀 247評論 0 0
  • 其一 悄然秋暮冷清宵,五嶺冥冥碧海遙。 檻外長燈傾斗柄,場中鐵索掛天橋。 車鳴人嘯沙塵急,錘響樁隆濾網搖。 翻遍《...
    歧堂閱讀 462評論 0 1
  • 看著羽毛筆的圖片,我內心多么想擁有一支屬于我的羽毛筆,潔白的顏色,像雪花一樣。羽毛筆啊羽毛筆,我想像這你在我手中揮...
    tadashi閱讀 520評論 0 1