Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review use of sync.Pool with slices #9

Open
jannson opened this issue Sep 21, 2017 · 2 comments
Open

Review use of sync.Pool with slices #9

jannson opened this issue Sep 21, 2017 · 2 comments

Comments

@jannson
Copy link

jannson commented Sep 21, 2017

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?

@jannson jannson closed this as completed Sep 21, 2017
@jannson
Copy link
Author

jannson commented Sep 21, 2017

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.

@c4milo c4milo changed the title bufferPool memory leak ? Review use of sync.Pool Sep 21, 2017
@c4milo
Copy link
Owner

c4milo commented Sep 21, 2017

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

@c4milo c4milo reopened this Sep 21, 2017
@c4milo c4milo changed the title Review use of sync.Pool Review use of sync.Pool with slices Sep 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants