GC: How was the object tree build?

88 views
Skip to first unread message

ding liu

unread,
Jul 24, 2019, 8:37:30 AM7/24/19
to golang-nuts
We know Go`s GC mark than can check all objects begin from root object. But how to build the object tree? I cann`t find any code in runtime, or any document. Any body has related documents?

Ian Lance Taylor

unread,
Jul 25, 2019, 1:46:04 AM7/25/19
to ding liu, golang-nuts
On Wed, Jul 24, 2019 at 5:37 AM ding liu <liudi...@gmail.com> wrote:
>
> We know Go`s GC mark than can check all objects begin from root object. But how to build the object tree? I cann`t find any code in runtime, or any document. Any body has related documents?

The GC never builds a tree. It marks the roots and puts them on a
worklist. Then it loops pulling an item off the worklist, tracing all
pointers, and putting all newly found objects on the worklist. This
loop is done concurrently with program execution. See the long
comment at the top of runtime/mgc.go.

Ian

ding liu

unread,
Jul 25, 2019, 10:30:56 PM7/25/19
to golang-nuts
Thanks

在 2019年7月25日星期四 UTC+8下午1:46:04,Ian Lance Taylor写道:
Reply all
Reply to author
Forward
0 new messages