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
bufio + net: memory leak #5318
Labels
Comments
Issue #5314 has been merged into this issue. |
attached output and heap profile code is: http://play.golang.org/p/bJF0etsZaE Attachments: |
Two pmaps about a minute apart: Attachments:
|
This combination leaks: reader := bufio.NewReader(conn) _, err = ioutil.ReadAll(reader) However, using only ioutil.ReadAll straight off the conn leads to no leak. _, err = ioutil.ReadAll(conn) Similarly, using only the bufio Read leads to no leak either. reader := bufio.NewReader(conn) reader.Read(make([]byte, 1)) As you can see from the gc.txt attachment, it doesn't leak on every loop, only every Nth loop. |
> This combination leaks: > > reader := bufio.NewReader(conn) > _, err = ioutil.ReadAll(reader) Does ioutil.ReadAll try to sense for the presence of ReadFrom/WriteTo ? What happens if you wrap reader in your own type that masks off the ReadFrom/WriteTo methods of bufio.Reader ? Status changed to WaitingForReply. |
Yay! Reduced the example to use os.Pipe to create a blocking fd read instead of the net package. Its a pretty simple function now, how someone can have a look. Attachments:
|
I don't see any bug here. The writer is never closed, so the reads will block forever, and the goroutines will leak and waste memory. Working as intended. Yes, the memory from Handle might not be collected as aggressively as possible, but that's the stack-precise GC that Carl is working on in issue #5134. But this program in comment #7 still has a leak. Status changed to Invalid. |
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: