On 26 Mar 2020, at 09:51, Tamás Gulácsi 
<tgulacs...@gmail.com<mailto: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.

Reply via email to