垃圾收集四讲
UVGE 刘清
• 历史与发展
• 优缺点
• 原理
• 实现
历史与发展
• LISP
• ML 系语言
• JVM
• C++
• Perl/Python/Ruby
• CLR
优缺点
优点:
a)方便
b)可靠
缺点:
• 时间及空间的开销
• 实现和移植的复杂性
( JVM 和 KVM )
• 底层操作的实现
• 对对象模型的影响
优缺点
改善:
• 可选式 GC
• 允许显式引入不安全操作
原理
• 引用计数
– 缺点:循环引用
循环引用
A
B
1
1
标记 - 清扫算法
• 寻找根对象并标记
• 按照广度优先遍历算
法进行遍历标记
• 任何被标记的都是存
活对象,不会被清除
• 进行清扫过程
√
√
√
√
原理
• 引用计数
– 缺点:循环引用
• 标记 - 清扫
– 缺点:效率
原理
• 引用计数
– 缺点:循环引用
• 标记 - 清扫
– 缺点:效率
• 分代式收集( 2 : 8 原则)
– 80% 的对象只存活于 %20 的程序生命期
分代式垃圾收集
Gen0
Gen1
Gen2
Gen0
分代式垃圾收集
Gen0
Gen1
Gen2
Gen0
分代式垃圾收集
Gen1
Gen2
Gen0
分代式垃圾收集
Gen1
Gen2
Gen0
分代式垃圾收集
Gen1
Gen2
Gen0
分代式垃圾收集
Gen2
Gen0
Gen1
分代式垃圾收集
Gen2
Gen0
Gen1
分代式垃圾收集
Gen2
Gen0
Gen1
分代式垃圾收集
Gen0
Gen2
Gen1
分代式垃圾收集
Gen0
Gen1
Gen2
Gen0
Gen2
Gen1
原理
• 引用计数
– 缺点:循环引用
• 标记 - 清扫
– 缺点:效率
• 分代式收集( 2 : 8 原则)
– 80% 的对象只存活于 %20 的程序生命期
• 复制 - 缩并
– 小内存:只使用缩并算法
实现

More Related Content

PPTX
Jvm memory
PDF
Sun jdk 1.6内存管理 -使用篇-毕玄
PDF
Java(script) on JVM
PDF
PDF
Chrome extensions dev Intro
PDF
Analyzing Java Applications Using Thermostat (Omair Majid)
PDF
Write Powerful Javascript Modules To Make Your Apps DRY (Brian Leathem)
PDF
Gimme Caching - The JCache Way
Jvm memory
Sun jdk 1.6内存管理 -使用篇-毕玄
Java(script) on JVM
Chrome extensions dev Intro
Analyzing Java Applications Using Thermostat (Omair Majid)
Write Powerful Javascript Modules To Make Your Apps DRY (Brian Leathem)
Gimme Caching - The JCache Way

Viewers also liked (19)

PDF
Vert.X mini-talk
PPTX
Breaking the Fourth Wall in Software
PPTX
From Imperative to Functional Programming (for Absolute Beginners)
PDF
Harnessing asynchronicity callbacks, promises, generators, and coroutines
PDF
In-Memory Computing - Distributed Systems - Devoxx UK 2015
PDF
Vert.x 3
PDF
Principles of the Play framework
PDF
An Adventure in Serverless ClojureScript
PPTX
Taming complexity in JavaScript
PDF
Recursion schemes in Scala
PPTX
Event driven microservices with vertx and kubernetes
PDF
Functional programming
PDF
Concurrency on the JVM
PPTX
Introducing to Asynchronous Programming
PPTX
autodiscoverable microservices with vertx3
PPTX
Lambda Calculus
PPT
Introduction to lambda expression & lambda calculus
PDF
Pointers and References
Vert.X mini-talk
Breaking the Fourth Wall in Software
From Imperative to Functional Programming (for Absolute Beginners)
Harnessing asynchronicity callbacks, promises, generators, and coroutines
In-Memory Computing - Distributed Systems - Devoxx UK 2015
Vert.x 3
Principles of the Play framework
An Adventure in Serverless ClojureScript
Taming complexity in JavaScript
Recursion schemes in Scala
Event driven microservices with vertx and kubernetes
Functional programming
Concurrency on the JVM
Introducing to Asynchronous Programming
autodiscoverable microservices with vertx3
Lambda Calculus
Introduction to lambda expression & lambda calculus
Pointers and References
Ad

Similar to Garbage collection (20)

PPT
快速搭建高性能服务端
PPTX
QCon - 一次 Clojure Web 编程实战
PDF
网站前端代码静态检查工具研究
PDF
网站前端代码静态检查工具综述
PDF
廣宣學堂: 企業導入微服務實戰
PDF
企業導入微服務實戰 - updated
PPTX
網路技術心得分享
PDF
企業導入微服務實戰 - updated
PDF
Debug Your Kubernetes Network
PPTX
调试技术的应用
PDF
推荐系统:从入门到放弃
PDF
Linux binary Exploitation - Basic knowledge
PDF
Nodejs & NAE
PPTX
Comment System of 56.com
PPTX
了解应用服务器
PPTX
Overview - QML and C++ Integration
PDF
mercury
PDF
合久必分,分久必合
PPTX
Duck Typing and Multiple Inheritance
PDF
COSCUP 2016 - LLVM 由淺入淺
快速搭建高性能服务端
QCon - 一次 Clojure Web 编程实战
网站前端代码静态检查工具研究
网站前端代码静态检查工具综述
廣宣學堂: 企業導入微服務實戰
企業導入微服務實戰 - updated
網路技術心得分享
企業導入微服務實戰 - updated
Debug Your Kubernetes Network
调试技术的应用
推荐系统:从入门到放弃
Linux binary Exploitation - Basic knowledge
Nodejs & NAE
Comment System of 56.com
了解应用服务器
Overview - QML and C++ Integration
mercury
合久必分,分久必合
Duck Typing and Multiple Inheritance
COSCUP 2016 - LLVM 由淺入淺
Ad

Garbage collection