Skip to content

Question: Is a chain of goroutines with empty select deletable? #36214

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

Closed
anqur opened this issue Dec 19, 2019 · 2 comments
Closed

Question: Is a chain of goroutines with empty select deletable? #36214

anqur opened this issue Dec 19, 2019 · 2 comments

Comments

@anqur
Copy link

anqur commented Dec 19, 2019

What version of Go are you using (go version)?

$ go version
go version go1.13.5 windows/amd64

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOOS=windows

What did you do?

The following code shows that the chain of goroutines A and B remains and intuitively I think they can be removed from the scheduler. Is this necessary to remove them or any reason that removing is not a good choice or that's just not a deal?

package main

import (
	"fmt"
	"runtime"
	"time"
)

func B() {
	select {}
}

func A() {
	B()
}

func main() {
	go A()
	for i := 0; i < 20; i++ {
		time.Sleep(1 * time.Second)
		fmt.Println(runtime.NumGoroutine())
	}
}

What did you expect to see?

1
1
...

What did you see instead?

2
2
...
@zigo101
Copy link

zigo101 commented Dec 19, 2019

The proposal to remove stale goroutines was rejected before: #19702

@anqur
Copy link
Author

anqur commented Dec 19, 2019

@go101 Thanks so much for the information! I'm closing this now.

@anqur anqur closed this as completed Dec 19, 2019
@golang golang locked and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants