5

深入理解 Go | 内存管理:垃圾收集(GC)

 3 years ago
source link: https://ictar.github.io/2020/04/25/dive-into-go-memory-gc/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

深入理解 Go | 内存管理:垃圾收集(GC)

发表于

2020-04-25 更新于 2021-01-26

阅读次数: 8 Disqus: 0 Comments

基于 Go 1.14

用户程序(Mutator)通过内存分配器(Allocator)在堆(Heap)上申请内存空间,而垃圾收集器(Collector)则负责回收不再使用的对象和内存空间。

标记清除(Mark-Sweep)算法

标记清除算法是最常见的垃圾收集算法,分为标记阶段和清除阶段。在整个垃圾收集的过程中,用户程序都是处于暂停(Stop the world, STW)状态。

三色标记法

为了解决原始的标记清除算法带来的长时间 STW 问题,三色标记法应运而生,它能缩短 STW 的时间。

增量垃圾收集和并发垃圾收集

为了减少应用程序暂停的最长时间以及垃圾收集的总暂停时间,会使用增量垃圾收集或者并发垃圾收集这两种策略来优化垃圾收集器。

Go 语言垃圾收集器的演进过程

Go 语言的具体实现

涉及的一些结构体和全局变量

垃圾收集的触发

垃圾收集的启动

请言小午吃个甜筒~~

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK