I got it.Thank you for your help

在 2019年8月21日星期三 UTC+8下午11:00:26,Ian Lance Taylor写道:
>
> On Wed, Aug 21, 2019 at 5:55 AM zct <tangzho...@bytedance.com 
> <javascript:>> wrote: 
> > 
> > I recently had  a goroutine leak problem, the code i reduced is like 
> this: https://play.golang.org/p/YW4hWoZZ7CD. 
> > 
> > The program is long-running and the finalizer is not called 
> > 
> > The RoomObj is deleted from map, why was it not released? Is it refereed 
> by the asyncChan object? 
> > 
> >  I don't understand here, can somebody explain the reason 
>
> Your finalizer itself is keeping the value alive. 
>
> runtime.SetFinalizer(a, func(r *RoomTest) { 
>     fmt.Println("SetFinalizer") 
>     close(a.asyncChan.a) 
> }) 
>
> You need to write the finalizer function to refer to r, not a.  The 
> reference to a in the finalizer function ensures that a is always 
> live. 
>
> Ian 
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/906c3d64-9211-4206-a2ee-1a0d881a35b7%40googlegroups.com.

Reply via email to