Files
NoteBook/JVM/2. 垃圾回收.md
2025-09-28 15:17:23 +08:00

37 lines
604 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 垃圾回收
**堆空间的结构**
- 新生代
- `Eden`
- `Survivor`
- S0
- S1
- 老年代
- 永久代 -> 元空间直接内存(JDK 8+)
**策略**
- 在创建对象时默认在 `Eden` 创建
- 大对象进入老年代
- 长期存活的对象进入老年代
**GC**
- 部分 GC
- Full GC
**死亡对象判断方法**
- 引用计数法
- 无法解决互相引用问题
- 可达性分析
- 主要方法
**垃圾收集算法**
- 标记-清除算法
- 复制算法
- 标记-整理算法
*实际上使用的是分代收集的方法,针对不同代的特点使用不同方法*