Isn't this because of the GC tracking these and treating then as
effectively weak references to borrow a Java term?
If they are not pointers they are not tracked by the GC and I guess they
could all be removed at every scan?
Just guessing though, I haven't in any way checked it.

On Thu, Mar 26, 2020 at 11:34 AM Jakob Borg <ja...@kastelo.net> wrote:

> On 26 Mar 2020, at 09:51, Tamás Gulácsi <tgulacs...@gmail.com> wrote:
>
>
> sync.Pool MUST use pointers (*[]byte)
>
>
> I've seen this a lot but I confess I don't understand it. A []byte is
> essentially a fat pointer, what does it matter if we put that or a *[]byte
> into the pool? I understand that putting a []byte will result in an
> allocation of a new []byte, but probably the purpose is to preserve and
> avoid reallocating the backing array, which might be large.
>
> Is there something fundamental about the sync.Pool that means that a put
> *must* be zero-allocation for it to function? Likely the calling code
> around the puts/gets are not zero-allocation either.
>
> //jb
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/DB9E8E73-10B0-451B-BE66-13AF2930BB74%40kastelo.net
> <https://groups.google.com/d/msgid/golang-nuts/DB9E8E73-10B0-451B-BE66-13AF2930BB74%40kastelo.net?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAKOF6942VjqZ21b5ztW6wn6FTuk_MZDNz%2B3p1v2Njr_RAwRO4w%40mail.gmail.com.

Reply via email to