On 09/28/2018 08:17 AM, Peter Mogensen wrote: > > > On 09/28/2018 03:04 AM, keith.rand...@gmail.com wrote: >> Objects returned by Get() are not special in any way. They will be GCd >> just like an object returned by new(). In fact, they will often be just >> a new()'d object. >> There is no association of such an object with the pool. A pool is just >> a fancy free list. Get might return a previously Put'd object instead of >> a new() one. >> >> Your scheme is unsafe. Storing a *Object as a uintptr means the >> underlying Object will be collected out from under your map. > > Ok... thanks... I guess I might have made the wrong assumption about > when objects returned from pool.Get() are subject to garbage collection. > However... (it's early here, so I forgot). Of course the uintptr entries in the map is not the only reference to the objects. In order to properly clean up there will be another datastructure holding (say) a linked list of the objects. For instance... if the map is only used as index to a huge database, where the objects are actually stored in a priority queue to, say, implement TTL or LRU. So, there would always be another reference to the objects preventing them for being garbage collected. /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.
- Re: [go-nuts] Huge map[string]*Object and GC where *Objec... Peter Mogensen
- Re: [go-nuts] Huge map[string]*Object and GC where *Objec... Dan Kortschak
- Re: [go-nuts] Huge map[string]*Object and GC where *Objec... Peter Mogensen
- Re: [go-nuts] Huge map[string]*Object and GC where *Objec... Dan Kortschak
- Re: [go-nuts] Huge map[string]*Object and GC where *Objec... Peter Mogensen
- Re: [go-nuts] Huge map[string]*Object and GC where *Objec... Ian Lance Taylor
- Re: [go-nuts] Huge map[string]*Object and GC where *Objec... Peter Mogensen
- Re: [go-nuts] Huge map[string]*Object and GC where *Objec... Francis
- Re: [go-nuts] Huge map[string]*Object and GC where *Objec... keith . randall
- Re: [go-nuts] Huge map[string]*Object and GC where *Objec... Peter Mogensen
- Re: [go-nuts] Huge map[string]*Object and GC where *Objec... Peter Mogensen
- Re: [go-nuts] Huge map[string]*Object and GC where *Objec... Keith Randall
- Re: [go-nuts] Huge map[string]*Object and GC where *Objec... Henrik Johansson
- Re: [go-nuts] Huge map[string]*Object and GC where *Objec... Peter Mogensen
- Re: [go-nuts] Huge map[string]*Object and GC where *Objec... Peter Mogensen
- Re: [go-nuts] Huge map[string]*Object and GC where *Objec... Henrik Johansson
- Re: [go-nuts] Huge map[string]*Object and GC where *Objec... Peter Mogensen
- Re: [go-nuts] Huge map[string]*Object and GC where *Objec... Jan Mercl
- Re: [go-nuts] Huge map[string]*Object and GC where *Objec... Henrik Johansson
- Re: [go-nuts] Huge map[string]*Object and GC where *Objec... Henrik Johansson
- Re: [go-nuts] Huge map[string]*Object and GC where *Objec... Dan Kortschak