Based on my experience and I believe many others, I would caution against the 
use of pools. Although it can be useful for objects that are very expensive to 
create/initialize using it in a more general case just to improve GC can be 
fraught with issues in a highly concurrent and/or complex system. It is much 
more difficult to know when an object can be “put back” and be sure there are 
no more references. This is why there is GC in the first place, to avoid the 
types of bugs this leads to. 

> On Sep 27, 2018, at 8:20 AM, Peter Mogensen <a...@one.com> wrote:
> 
> 
> 
>> On 09/27/2018 03:12 PM, Ian Davis wrote:
>> 
>> 
>>> On Thu, 27 Sep 2018, at 2:04 PM, Peter Mogensen wrote:
>>> 
>>> Of course... it requires that you handle any collisions in hashing the
>>> string key to an int yourself, but wrt. the value I curious if anyone
>>> can see issued with just storing a uintptr instead of the pointer for
>>> sync.Pool managed objects. - (provided you remember to call pool.Put()
>>> before loosing the map reference or doing delete() on a key.)
>>> 
>>> m[key] = uintptr(unsafe.Pointer(pool.Get().(*Object)))
>>> 
>> 
>> sync.Pools are cleared on every GC run so I expect that will cause some 
>> issues with your approach
>> 
> 
> I don't think so... the point being that the "huge" part comes from a
> lot of objects tied up in the map, not so much in the garbage pile.
> Of course I would still like Objects which I don't use anymore to be
> collected. I just don't want the map to be checked for Objects I've
> already promised myself to tell when are garbage.
> 
> /Peter
> 
> -- 
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to