-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
Memory leak in using slice of channels #43433
Comments
Please explain how exactly are you determining the amount of memory effectively used by the process, and thus that there's a leak. Keep in mind that Go 1.15 on linux uses MADV_FREE to return memory, so the usual top/htop statistics will not be updated unless the OS actually reclaims the memory. But the Go program is not actually reserving the amount of memory shown. See #42330. |
This is how I determine amount of memory usage: (This code is run)
And continuing this way, the memory usage keeps going up until the whole RAM is used and process is killed by kernel
I have 16GB RAM + 8GB swap which was fully consumed by entering 100000 for 3 times |
If you add explicit |
you're allocating too much memory too fast. the scavenger wont return unused memory back to os until after a certain amount of time. (this used to be 5 minutes) |
Channels are 96 bytes, plus 8 for the entry in the Get a larger machine, or set I'm going to close, as I don't think there's a bug here. If you can demonstrate otherwise (heap growing to >2x live data), please reopen. |
Thanks for explaining, calling |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Creating many channels inside slice (and not using them), garbage collector does not free them
This is the code I run: https://play.golang.org/p/0OaEXpZukQ9
What did you expect to see?
I expect to see memory usage be dropped when not using created objects
What did you see instead?
I see that memory usage never goes down and more memory is reserved for each iteration (i.e. there is memory leak)
The text was updated successfully, but these errors were encountered: