It can get expensive to do that. Instead of just a mark bit per object, and
a queue of pointers to mark, you need a mark bit per word and a queue of
ptr+len. You can also end up doing more than constant work per mark.
x := [10]*int{ ... 10 pointers ... }
a := x[:3:3]
b := x[7::]
x is now dead,
On Sat, Jan 11, 2020 at 4:43 AM wrote:
>> But there's one guarantee - the "dead" slice portion after
>> cap will not be scanned by the collector if no other live object uses
>> it.
>
>
> That's not correct. If there is a reference to an object, the entire object
> is live and is scanned,
On Friday, January 10, 2020 at 1:02:22 AM UTC-8, Jan Mercl wrote:
>
> On Fri, Jan 10, 2020 at 9:52 AM Christophe Meessen
> > wrote:
> >
> > It is possible to reduce the capacity of a slice by using the full slice
> expression (https://golang.org/ref/spec#Slice_expressions).
> >
> > Now
On Fri, Jan 10, 2020 at 9:52 AM Christophe Meessen
wrote:
>
> It is possible to reduce the capacity of a slice by using the full slice
> expression (https://golang.org/ref/spec#Slice_expressions).
>
> Now consider the following code where a is a 1MB slice. I then create b, a
> slice of a, but
It is possible to reduce the capacity of a slice by using the full slice
expression (https://golang.org/ref/spec#Slice_expressions).
Now consider the following code where a is a 1MB slice. I then create b, a
slice of a, but with a much smaller capacity. Finally, I change the value
of a so that