What kind of Garbage Collection does Go use?

后端 未结 5 2052
余生分开走
余生分开走 2020-12-02 04:58

Go is a garbage collected language:

http://golang.org/doc/go_faq.html#garbage_collection

Here it says that it\'s a mark-and-sweep garbage collector, but it d

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-02 05:37

    This is the implementation of the GC:

    https://github.com/golang/go/blob/master/src/runtime/mgc.go

    From the docs in the source:

    The GC runs concurrently with mutator threads, is type accurate (aka precise), allows multiple GC thread to run in parallel. It is a concurrent mark and sweep that uses a write barrier. It is non-generational and non-compacting. Allocation is done using size segregated per P allocation areas to minimize fragmentation while eliminating locks in the common case.

提交回复
热议问题