Skip to content

Commit 283232c

Browse files
committed
update gc
1 parent 61d3f57 commit 283232c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

gc.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ init --> forcegchelper
101101
forcegchelper --> gcStart
102102
```
103103

104-
其实就是 mallocgc,shouldhelpgc,runtime.GC 这三个入口。
104+
其实就是 mallocgc,forcegchelper,runtime.GC 这三个入口。
105+
106+
* mallocgc,分配堆内存时触发,会检查当前是否满足触发 gc 的条件,如果触发,那么进入 gcStart。
107+
* forcegchelper,在 forcegchelper 中会把 forcegc.g 这个全局对象的运行 g 挂起。sysmon 会调用 test 检查上次触发 gc 的时间到当前时间是否已经经过了 forcegcperiod 长的时间,如果已经超过,那么就会将 forcegc.g 注入到 globrunq。这样会在该 g 被调度到的时候触发 gc。
108+
* runtime.GC 是由用户主动触发的。
105109

106110
## runtime.GC
107111

0 commit comments

Comments
 (0)