FAQ
Thx you all for your replies. As previously writen here, what awesome
community you are :)
The pool will be cleared during garbage collection, it is not a cache.
This also mitigates your previous point, putting too many things into a
pool will cause a garbage collection cycle, which will empty the pool.
If I understand correctly, when the garbage collection is running, it will
remove all elements stored into sync.Pool regardless of the size of this
sync.Pool or regardless of when this element has been last time used.

Plz correct me, if I am wrong.
With this kind of behavior, when the gc is launched (because there is some
memory allocation elsewhere into the program) and for one specific loading
(e.g x QPS) it is likely that all needed elements (for managing this
specific QPS) will be out of sync.Pool, and so they won't be removed by gc
(because there are actually used).
The sync.Pool will find automatically the correct size of elements
regardless the loading, and gc will be remove all unnecessary elements
(e.g. previously created during a last burst)
For my point of view, this seems to be a very elegant way to find the
optimal size of sync.Pool unlike the channel where you have to tune its
size by rule of thumb or by more scientific approach.


Le lundi 19 octobre 2015 11:25:45 UTC+2, Dave Cheney a écrit :
- with sync.Pool, buffer can be garbage collected even if there are stored
into sync.Pool (kind of java.lang.ref.WeakReference)
The pool will be cleared during garbage collection, it is not a cache.
This also mitigates your previous point, putting too many things into a
pool will cause a garbage collection cycle, which will empty the pool.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 7 of 8 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedOct 18, '15 at 2:54p
activeOct 20, '15 at 7:53a
posts8
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase