Re: [go-nuts] Why makechan distinguish elements do not contain pointers or contain pointers?

2019-01-28 Thread Ian Lance Taylor
On Sun, Jan 27, 2019 at 6:21 PM wrote: > > It is in line 899 and line 914 of the malloc.go file. > > 899 spc := makeSpanClass(sizeclass, noscan) > 914 s = largeAlloc(size, needzero, noscan) Thanks, I wasn't aware of that. Looks like we have spans that contain only objects without pointers, and

Re: [go-nuts] Why makechan distinguish elements do not contain pointers or contain pointers?

2019-01-27 Thread mountainfpf
It is in line 899 and line 914 of the malloc.go file. 899 spc := makeSpanClass(sizeclass, noscan) 914 s = largeAlloc(size, needzero, noscan) 在 2019年1月27日星期日 UTC+8下午1:55:29,Ian Lance Taylor写道: > > On Sat, Jan 26, 2019 at 6:50 PM > wrote: > > > > I am looking at go1.11.1. > > I don't see a

Re: [go-nuts] Why makechan distinguish elements do not contain pointers or contain pointers?

2019-01-26 Thread Ian Lance Taylor
On Sat, Jan 26, 2019 at 6:50 PM wrote: > > I am looking at go1.11.1. I don't see a "noscan" flag for mallocgc in 1.11.1. There is a noscan local variable, which is set of the type is passed as nil (the case I mentioned earlier) or if the type has no pointers. > The memory allocation is still

Re: [go-nuts] Why makechan distinguish elements do not contain pointers or contain pointers?

2019-01-26 Thread mountainfpf
I am looking at go1.11.1. The memory allocation is still difficult to understand. What reference materials can help me understand the context of this block? 在 2019年1月27日星期日 UTC+8上午3:03:47,Ian Lance Taylor写道: > > On Sat, Jan 26, 2019 at 5:37 AM > wrote: > > > > Why the garbage collector won't

Re: [go-nuts] Why makechan distinguish elements do not contain pointers or contain pointers?

2019-01-26 Thread Ian Lance Taylor
On Sat, Jan 26, 2019 at 5:37 AM wrote: > > Why the garbage collector won't know how to find the pointers? > I looked at mallocgc and decided if the GC needs to scan this object based > on the noscan flag. What version of Go are you looking at? There was a flagNoScan as late as Go 1.6, but

Re: [go-nuts] Why makechan distinguish elements do not contain pointers or contain pointers?

2019-01-26 Thread mountainfpf
Why the garbage collector won't know how to find the pointers? I looked at mallocgc and decided if the GC needs to scan this object based on the noscan flag. 在 2019年1月25日星期五 UTC+8下午10:58:44,Ian Lance Taylor写道: > > On Thu, Jan 24, 2019 at 11:58 PM > > wrote: > > > > go 1.11.1 source code is

Re: [go-nuts] Why makechan distinguish elements do not contain pointers or contain pointers?

2019-01-25 Thread Ian Lance Taylor
On Thu, Jan 24, 2019 at 11:58 PM wrote: > > go 1.11.1 source code is below: > > Generally speaking, make chan just pay attention to the presence or absence > of buf. > > When I saw the source code of make chan, I can understand case 1: chan buf > is 0, but can't understand case 2 & default. >

[go-nuts] Why makechan distinguish elements do not contain pointers or contain pointers?

2019-01-24 Thread mountainfpf
go 1.11.1 source code is below: Generally speaking, make chan just pay attention to the presence or absence of buf. When I saw the source code of make chan, I can understand case 1: chan buf is 0, but can't understand case 2 & default. Who knows this principle? Thanks! var c *hchan