-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: probably excessive garbage collection on objects using finalizer #14910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is not a bug, IMO. f is not live by the time the loop starts, and it On Tue, 22 Mar 2016, 19:47 Mikio Hara, notifications@github.com wrote:
|
It works fine when we add a reference for keeping os.File live like
|
I know it won't happen, but I think we should remove the finalisers from On Tue, 22 Mar 2016, 19:54 Mikio Hara, notifications@github.com wrote:
|
Perhaps it might be better to mention that os.File and net.{Conn,PacketConn,Listener} use runtime.SetFinalizer. |
The bug is that the program does not close f, instead it relies on the This is one of the gotchas from relying on finalizers. On Tue, Mar 22, 2016 at 5:17 AM, Mikio Hara notifications@github.com
|
I don't see anything to do here. The doc comment for os.File.Fd says "The file descriptor is valid only until f.Close is called or f is garbage collected." That is, if you call Fd, you are responsible for explicitly keeping the os.File alive. |
Please answer these questions before submitting your issue. Thanks!
go version
)?tip through go1.4
go env
)?{dragonfly,freebsd,linux,openbsd,netbsd}/amd64
ran the following snippet:
no error output
The text was updated successfully, but these errors were encountered: