On Thu, 16 Feb 2017 00:29:04 -0800 (PST) caspia...@gmail.com wrote: > > > Will GC close unused connection ? > > > > No. At least not directly. A finalizer can possibly do that and > > finalizers are possibly invoked by the GC. [...] > Means yes, GC will close unused connection, just indirectly? > Cause I found this: > #/opt/go/src/net/fd_unix.go > func (fd *netFD) setAddr(laddr, raddr Addr) { > fd.laddr = laddr > fd.raddr = raddr > runtime.SetFinalizer(fd, (*netFD).Close) > } > > And this function is called by netFD.dial in sock_posix.go:148
It means "the runtime _may_ eventually close the connection after the Go's value wrapping it was garbage-collected, but this is not guaranteed to happend, and quite likely it will not happen". Please read this recent thread [1] dealing with finalizers. 1. https://groups.google.com/d/topic/golang-nuts/d8aF4rAob7U/discussion -- 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.