auto commit
|
@ -30,7 +30,7 @@
|
|||
|
||||
# 一、运行时数据区域
|
||||
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/83e9c5ed-35a1-41fd-b0dd-ce571969b5f3_200.png" width="500px"> </div><br>
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/5778d113-8e13-4c53-b5bf-801e58080b97.png" width="400px"> </div><br>
|
||||
|
||||
## 程序计数器
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
|||
|
||||
每个 Java 方法在执行的同时会创建一个栈帧用于存储局部变量表、操作数栈、常量池引用等信息。从方法调用直至执行完成的过程,就对应着一个栈帧在 Java 虚拟机栈中入栈和出栈的过程。
|
||||
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/ff5b89ac-798e-4fbc-b0ce-da2fc2358570.jpg"/> </div><br>
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/8442519f-0b4d-48f4-8229-56f984363c69.png" width="400px"> </div><br>
|
||||
|
||||
可以通过 -Xss 这个虚拟机参数来指定每个线程的 Java 虚拟机栈内存大小:
|
||||
|
||||
|
@ -59,7 +59,7 @@ java -Xss512M HackTheJava
|
|||
|
||||
本地方法一般是用其它语言(C、C++ 或汇编语言等)编写的,并且被编译为基于本机硬件和操作系统的程序,对待这些方法需要特别处理。
|
||||
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/1_2001550547261811.png"/> </div><br>
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/66a6899d-c6b0-4a47-8569-9d08f0baf86c.png" width="300px"> </div><br>
|
||||
|
||||
## 堆
|
||||
|
||||
|
@ -144,7 +144,8 @@ Java 虚拟机使用该算法来判断对象是否可被回收,GC Roots 一般
|
|||
- 方法区中类静态属性引用的对象
|
||||
- 方法区中的常量引用的对象
|
||||
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/6dd28bfc-6ef7-47cb-af50-a681ebc1bbaa.png"/> </div><br>
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/83d909d2-3858-4fe1-8ff4-16471db0b180.png" width="350px"> </div><br>
|
||||
|
||||
|
||||
### 3. 方法区的回收
|
||||
|
||||
|
@ -224,8 +225,7 @@ obj = null;
|
|||
|
||||
### 1. 标记 - 清除
|
||||
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/3_2001550547558008.png"/> </div><br>
|
||||
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/005b481b-502b-4e3f-985d-d043c2b330aa.png" width="400px"> </div><br>
|
||||
|
||||
在标记阶段,程序会检查每个对象是否为活动对象,如果是活动对象,则程序会在对象头部打上标记。
|
||||
|
||||
|
@ -240,7 +240,7 @@ obj = null;
|
|||
|
||||
### 2. 标记 - 整理
|
||||
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/2_2001550547456403.png"/> </div><br>
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/ccd773a5-ad38-4022-895c-7ac318f31437.png" width="400px"> </div><br>
|
||||
|
||||
让所有存活的对象都向一端移动,然后直接清理掉端边界以外的内存。
|
||||
|
||||
|
@ -254,7 +254,7 @@ obj = null;
|
|||
|
||||
### 3. 复制
|
||||
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/4_2001550547640585.png"/> </div><br>
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/b2b77b9e-958c-4016-8ae5-9c6edd83871e.png" width="400px"> </div><br>
|
||||
|
||||
将内存划分为大小相等的两块,每次只使用其中一块,当这一块内存用完了就将还存活的对象复制到另一块上面,然后再把使用过的内存空间进行一次清理。
|
||||
|
||||
|
@ -456,7 +456,7 @@ G1 把堆划分成多个大小相等的独立区域(Region),新生代和
|
|||
|
||||
## 类的生命周期
|
||||
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/303873db-0d11-4683-a43c-f319b7aef2b6.jpg"/> </div><br>
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/335fe19c-4a76-45ab-9320-88c90d6a0d7e.png" width="600px"> </div><br>
|
||||
|
||||
包括以下 7 个阶段:
|
||||
|
||||
|
@ -629,7 +629,7 @@ System.out.println(ConstClass.HELLOWORLD);
|
|||
|
||||
下图展示了类加载器之间的层次关系,称为双亲委派模型(Parents Delegation Model)。该模型要求除了顶层的启动类加载器外,其它的类加载器都要有自己的父类加载器。这里的父子关系一般通过组合关系(Composition)来实现,而不是继承关系(Inheritance)。
|
||||
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/805812fa-6ab5-4b8f-a0aa-3bdcadaa829d.png"/> </div><br>
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/0dd2d40a-5b2b-4d45-b176-e75a4cd4bdbf.png" width="500px"> </div><br>
|
||||
|
||||
### 1. 工作过程
|
||||
|
||||
|
|
BIN
docs/pics/005b481b-502b-4e3f-985d-d043c2b330aa.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
docs/pics/0dd2d40a-5b2b-4d45-b176-e75a4cd4bdbf.png
Normal file
After Width: | Height: | Size: 45 KiB |
BIN
docs/pics/335fe19c-4a76-45ab-9320-88c90d6a0d7e.png
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
docs/pics/5778d113-8e13-4c53-b5bf-801e58080b97.png
Normal file
After Width: | Height: | Size: 73 KiB |
BIN
docs/pics/66a6899d-c6b0-4a47-8569-9d08f0baf86c.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
docs/pics/83d909d2-3858-4fe1-8ff4-16471db0b180.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
docs/pics/8442519f-0b4d-48f4-8229-56f984363c69.png
Normal file
After Width: | Height: | Size: 41 KiB |
BIN
docs/pics/b2b77b9e-958c-4016-8ae5-9c6edd83871e.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
docs/pics/ccd773a5-ad38-4022-895c-7ac318f31437.png
Normal file
After Width: | Height: | Size: 13 KiB |