Review use of sync.Pool with slices
jannson opened this issue · comments
Jason commented
As I known, the sync.Pool in golang , you must use get/put together. But the code below
https://github.com/c4milo/gsync/blob/master/gsync_client.go#L109
you only bufferPool.Put(bfp) when the err is io.EOF, is this ok?
Jason commented
I find that buffer from synt.Pool can be gc when the sync.Pool hold the only reference.
https://golang.org/src/sync/pool.go line 17
But you should put the buffer to bufferPool event it can be gc outside.
Camilo Aguilar commented
@jannson, there is no memory leak as you found out. However, it does put pressure in the GC.