Navigation Menu

Skip to content
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

goroutine leak #22773

Closed
widon1104 opened this issue Nov 17, 2017 · 3 comments
Closed

goroutine leak #22773

widon1104 opened this issue Nov 17, 2017 · 3 comments

Comments

@widon1104
Copy link

widon1104 commented Nov 17, 2017

Please answer these questions before submitting your issue. Thanks!

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

go1.9

Does this issue reproduce with the latest release?

yes

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

ubuntu17.10

What did you do?

If possible, provide a recipe for reproducing the error.
I don't which code cause the problem yet.

What did you expect to see?

goroutine num do not increase

What did you see instead?

I use pprof to get my goroutine num, I do nothing but my goroutine num continue increase, the init value is 55, but after a night, the goroutine num increase to 1779.Dose someone give me some suggestion ?
The pprof output:

goroutine profile: total 1779
869 @ 0x4c974c 0x4d9228 0x822125 0x4f65c1
0x822124 net/http.(*persistConn).writeLoop+0x164 /usr/local/go/src/net/http/transport.go:1759

866 @ 0x4c974c 0x4d9228 0x820f97 0x4f65c1
0x820f96 net/http.(*persistConn).readLoop+0x7a6 /usr/local/go/src/net/http/transport.go:1654

@bronze1man
Copy link
Contributor

Looks like http server tcp connection leak.
Set ReadTimeout/IdleTimeout on *http.Server and call Server.SetKeepAlivesEnabled may solve your problem.

@ALTree
Copy link
Member

ALTree commented Nov 17, 2017

Hi,

the Go project does not use its bug tracker for general discussion or asking questions about the language. The Github bug tracker is only used for tracking bugs and proposals going through the Proposal Process.

Please see the Questions wiki page; it has a list of good places for asking questions. Thanks!

Closing, since this is not a bug in Go. We can re-open if it turns out this was actually a bug in the Go http library.

@ALTree ALTree closed this as completed Nov 17, 2017
@bradfitz
Copy link
Contributor

Read the docs at https://golang.org/pkg/net/http/#Transport which says:

By default, Transport caches connections for future re-use. This may leave many open connections when accessing many hosts. This behavior can be managed using Transport's CloseIdleConnections method and the MaxIdleConnsPerHost and DisableKeepAlives fields.

Transports should be reused instead of created as needed. Transports are safe for concurrent use by multiple goroutines.

@golang golang locked and limited conversation to collaborators Nov 17, 2018
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

5 participants