Due to these local pools, the ideal scenario for using sync.Pool is where objects are retrieved and released in the same goroutine, so these objects will belong to the same local processor pool where goroutine runs. For example, an object is retrieved from the pool in one goroutine, and then passed to another goroutine, which uses the object and returns it to the pool. // // pools[0] is for capacities from 0 to 8 // pools[1] is for capacities from 9 to 16 // pools[2] is for capacities from 17 to 32 // ... // pools[n] is for capacities from 2^(n+2)+1 to 2^(n+3) // // Limit the maximum capacity to 2^18, since there are no performance benefits // in caching byte slices with bigger capacities.