golang 博文 阅读笔记

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/haolipengzhanshen/article/details/89491327

Goroutine Leaks - The Forgotten Sender

https://www.ardanlabs.com/blog/2018/11/goroutine-leaks-the-forgotten-sender.html

解决办法:将无缓冲的channel换成有缓冲的channel,其容量为1

Now in the timeout case,after the receiver has moved on,the search Goroutine will complete its send by placing the result value in the channel the it will return.

this memory for that Goroutine will eventually be reclaimed as well the memory for the channel.

猜你喜欢

转载自blog.csdn.net/haolipengzhanshen/article/details/89491327
今日推荐