c4milo / gsync

gSync is an rsync based library for sending delta updates of files to a remote server.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Review use of sync.Pool with slices

jannson opened this issue · comments

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?

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.

@jannson, there is no memory leak as you found out. However, it does put pressure in the GC.