Goroutine没有顺利结束
1、这里更多的是由于channel+for+select导致的,错误的写法导致了发送者或接收者没有发现channel已经关闭,任务已经结束了,却仍然在尝试输入输出https://geektutu.com/post/hpg-exit-goroutine.html
Map的remove方法不会真正的删除某个key,内存会无限增长
不要把map用作全局
timer的错误用法
//错误用法
for{select {//这里timer会生成一个新变量,在timer到期之前会一直占用内存case <-time.After(duration):fmt.Println("process request with", duration)}}
//正确用法
idleDelay := time.NewTimer(idleDuration)
defer idleDelay.Stop()
for{idleDelay.Reset(idleDuration)select {case <-idleDelay.C:fmt.Println("process request with", duration)}}