Thanks! I'm going to read it carefully.
在 2017年2月16日星期四 UTC+8下午4:40:54,Konstantin Khomoutov写道:
>
> On Thu, 16 Feb 2017 00:29:04 -0800 (PST)
> casp...@gmail.com wrote:
>
> > > > Will GC close unused connection ?
> > >
> > > No. At least not directly. A finalizer can possibly do that and
> > >
Many thanks!
Yes, I know that it is wrong to keep connection without call Close func.
just when I working on a bug, I found the connection was closed
automatically somehow.
在 2017年2月16日星期四 UTC+8下午4:33:54,Axel Wagner写道:
>
> Yes, in general, the GC will usually close connections when the
> corre
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?
>
Yes, in general, the GC will usually close connections when the
corresponding files are collected. But a) you can't really rely on that and
b) the number of file descriptors that a program can open is very limited
and for many programs, the rate at which they are opened is high enough,
that they wi
Thanks for you reply!
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
On Thu, Feb 16, 2017 at 8:20 AM 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.
--
-j
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To u
Will GC close unused connection ?
In a particular case, I found that if there's a connection won't be used
for a while, it will be closed. If I disable GC, then the connection will
not be closed.
In the test, I never call the close function manually. But this is a bit
hard to reproduce.
GC will