One of the series JVM: JVM architecture

1 Introduction

  Java platform can be divided into two parts, namely the Java Virtual Machine (Java virtual machine, JVM) and Java API class libraries.

  JVM is an acronym for Java Virtual Machine (Java virtual machine), JVM enables Java implementation of the cross-platform.

  After the introduction of Java virtual machine language, Java language does not need to be recompiled to run on different platforms when. Java Virtual Machine using Java language information associated with a particular shielding platform, so that only Java language compiler to generate object code that runs on the Java virtual machine (byte code) , can be run without modification on multiple platforms .

2. JVM Chart

  Java Virtual Machine is divided into five modules: the class loader subsystem, run-time data area, execution engine, native method interface and garbage collection module.

The main function of each part:

  Class loader : JVM startup, the program begins execution, bytecode class responsible for loading into the JVM memory area

  Execution Engine : responsible for executing bytecode instruction class contained in the file

  Native method libraries  : The main method is to call native C or C ++ implementation and returns the result

  Run-time data area [focus]

    The method area (Area Method,) : class structure for storing local information, including the constant pool, static variables, and other constructors .

    java heap (Heap) : storing java objects or instances place. This is the main area of the GC . Heap and method area is shared by all java threads.

    java栈(Stack) :java栈总是和线程关联在一起,每当创建一个线程时,JVM就会为这个线程创建一个对应的java栈。在这个java栈中又会包含多个栈帧,每运行一个方法就创建一个栈帧,用于存储局部变量表、操作栈、方法返回值等。每一个方法从调用直至执行完成的过程,就对应一个栈帧在java栈中入栈到出栈的过程。所以java栈是现成私有的。

    程序计数器(PC Register) :程序计数器是一块较小的内存空间,可以看作是当前线程所执行的字节码的行号指示器。分支、循环、跳转、异常处理、线程恢复等基础功能都需要依赖这个计数器来完成。

    本地方法栈(Native Method Stack) :和java栈的作用差不多,只不过是为JVM使用到的native方法服务的。

 

 3. JVM内部模块间的关系

 

这里写图片描述

垃圾回收系统:方法区、Java堆

类加载器:方法区

执行引擎:方法区、Java堆、Java栈、PC寄存器

 

摘录自

https://note.youdao.com/ynoteshare1/index.html?id=920f10f97acfc22fe0c27cc52a97cb28&type=note

【Java面试整理之JVM】深入理解JVM结构、类加载机制、垃圾回收GC原理、JVM内存分配策略、JVM内存泄露和溢出

Guess you like

Origin www.cnblogs.com/haimishasha/p/11229144.html