-
Notifications
You must be signed in to change notification settings - Fork 18k
io: MultiReader doesn't free input readers after use (Go 1.7) #16983
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
Comments
There is something more troubling about MultiReader. Even when MultiReader is collected, the readers are not. See https://play.golang.org/p/9dX8bk8P_I. |
I put the example above in a loop and I now can see r1s are collected later in the program's life. It is just not immediately collected in the first passes. Maybe because of the mr->r1 dependency. |
CL https://golang.org/cl/28533 mentions this issue. |
CL https://golang.org/cl/28771 mentions this issue. |
Updates #16983 Updates #16996 Change-Id: I76390766385b2668632c95e172b2d243d7f66651 Reviewed-on: https://go-review.googlesource.com/28771 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
I've noticed that io.MultiReader doesn't set input reader references to nil before shrinking its slice. From my understanding of Go's garbage collector this means that the Readers won't be freed before the whole underlying array is freed.
In other words I propose that:
is changed to:
In my encounter with this issue, the MultiReader may unnecessarily hold references to potentially large buffers (8 MB) for extended periods of time, wasting memory.
The text was updated successfully, but these errors were encountered: