5 ms·
There is sync.Pool [0] but I wouldn't reach for it until you've profiled your application[1] and found that the specific allocation in question is a hot spot.
by kevinconaway 7y ago
There is sync.Pool [0] but I wouldn't reach for it until you've profiled your application[1] and found that the specific allocation in question is a hot spot.
As of now[2], they get cleared when a GC occurs so they can be a bit quirky to use in practice. This behavior is changing though
[0] https://golang.org/pkg/sync/#Pool https://golang.org/pkg/sync/#Pool
[1] https://blog.golang.org/profiling-go-programs https://blog.golang.org/profiling-go-programs
[2] https://github.com/golang/go/issues/22950 https://github.com/golang/go/issues/22950