-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: finalizers keep data live for a surprising amount of time #5348
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
Labels
Comments
Carl theorized that this was related to his work on issue #353 & issue #5134. To test that theory, he was curious to see what happened if you ran foo in a goroutine, with its own stack. No change: $ cat z.go package main import ( "fmt" "runtime" ) type T struct { S *string } func newString(s string) *string { return &s } func foo() { t := &T{S: newString("foo")} runtime.SetFinalizer(t, func(p *T) { fmt.Println("GC T") }) runtime.SetFinalizer(t.S, func(p *string) { fmt.Println("GC string") }) } func main() { fmt.Println("hi") donec := make(chan bool) go func() { foo() donec <- true }() <-donec runtime.GC() runtime.GC() fmt.Println("bye") } $ go run --ldflags=-Z z.go hi GC T bye Likewise if making the channel buffered or putting in a big sleep after the channel receive. |
No patch is attached. In general we don't use issue tracker attachments for patches, though... for CLA and reviewability reasons. If we use rietveld, then others can patch in your patch easily with "hg clpatch NNNNNN". But you're aware of http://golang.org/doc/contribute.html |
Corrected source code with predictable behavior: http://play.golang.org/p/nC4wJ5hapl |
This issue was closed by revision e9bbe3a. Status changed to Fixed. |
This issue was closed by revision db1c218. |
This issue was closed by revision eb04df7. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: