Documentation Index
Fetch the complete documentation index at: https://amigoer.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
JVM(Java Virtual Machine)是 Java 程序的运行环境,负责将 Java 字节码翻译成机器码执行。深入理解 JVM 对于编写高性能 Java 程序和解决生产问题至关重要。
核心内容
1. JVM 内存结构
2. 类加载机制
- 类加载过程:加载、验证、准备、解析、初始化
- 类加载器:Bootstrap、Extension、Application
- 双亲委派模型
3. 垃圾回收
- 垃圾判定算法:引用计数、可达性分析
- 垃圾回收算法:标记清除、复制、标记整理
- 垃圾收集器:Serial、Parallel、CMS、G1、ZGC
4. JVM 调优
JVM 架构图
┌─────────────────────────────────────────────────────────────┐
│ Class Files │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ Class Loader │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ Bootstrap │→ │ Extension │→ │ Application │ │
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ Runtime Data Area │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌────────────┐ │
│ │ Method │ │ Heap │ │ VM Stack │ │ PC Reg │ │
│ │ Area │ │ │ │ │ │ │ │
│ └──────────┘ └──────────┘ └──────────┘ └────────────┘ │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ Execution Engine │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ Interpreter │ │ JIT Compiler│ │ Garbage Collector │ │
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ Native Method Interface │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ Native Method Library │
└─────────────────────────────────────────────────────────────┘
本系列文章基于 JDK 8 / JDK 11 编写,涵盖了 JVM 的核心知识点。理解 JVM 原理有助于:
- 编写更高效的 Java 代码
- 合理配置 JVM 参数
- 快速定位和解决生产问题
- 深入理解 Java 语言特性
参考资料