doc: document that sync.Pool should be used only with pointer types #16323
Labels
Documentation
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
To avoid spurious allocations, sync.Pool should always be used with pointers. For instance, when storing buffers as slices, a pointer to slice should be used instead of the slice itself. This was brought up in http://golang.org/cl/24371 by @dvyukov, but it's not documented.
Since the primary goal of sync.Pool is to reduce allocations, and using it with non-pointers makes it de-facto useless, it should be prominently documented to avoid using non-pointers with it.
The text was updated successfully, but these errors were encountered: