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
net/http: http2 Transport retains Request.Body after request is complete, not GCed #14084
Comments
Interesting. I wrote a test that reproduces this (in https://go-review.googlesource.com/18873) but I can't figure out what's retaining the memory. As far as I can tell, it should be GC'ed. /cc @aclements @randall77 for help if either of you have time. |
It also occurs on 1.5. I take it it's nontrvial to see what is referencing the bytes ? |
We have a heap dumper and tools to kinda view said heap but I'm not sure how to really use it these days. |
CL https://golang.org/cl/18873 mentions this issue. |
It's being held alive because it is in the reqCanceler map. Does that help any? tracealloc(0xc820114ee0, 0x20, strings.Reader) |
Perfect! That helps a ton. How did you get that output? |
I added a print statement to print the address of the strings.Reader. |
Great, thanks |
This doesn't seem to have fixed it. |
I had a play with your test. If I make the server response have an empty body, by removing the line |
@anacrolix, nice! Confirmed. And that one's a bug in http2, not in the net/http integration. Easy fix: https://go-review.googlesource.com/19134 |
CL https://golang.org/cl/19134 mentions this issue. |
…TREA Prevents a memory leak. Tests (to be updated) in Go standard library. Updates golang/go#14084 Change-Id: I3ff602a013bb8fda7a17bccb31beadb08421ae6a Reviewed-on: https://go-review.googlesource.com/19134 Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
CL https://golang.org/cl/19135 mentions this issue. |
I believe there's some kind of memory leak when using the following Client.
b []byte
below is typically 16KB at a time, and is never GC'd after having entered this section of code. Memory use climbs proportional to the number of requests sent on the client. I've ruled out the calling code. It didn't occur before I switched to h2 from HTTP/1.1. I assume some kind of h2 session-related item isn't being cleaned-up due to my unusual configuration.The text was updated successfully, but these errors were encountered: