chenwei113524 opened a new pull request #148:
URL: https://github.com/apache/servicecomb-mesher/pull/148


   当在for循环里使用select + time.After的组合时会产生内存泄露
    
         for  {
                  conn, err := l.AcceptTCP()
                if err != nil {
                        select {
                        case <-time.After(time.Second * 3):
                                openlog.Info("Sleep three second")
                        }
                }
                dubbConn := d.connMgr.GetConnection(conn)
                dubbConn.Open()
         }
   
   可以改成:
   
       timer := time.NewTimer(time.Second * 3)
        defer timer.Stop()
        for {
                conn, err := l.AcceptTCP()
                if err != nil {
                        select {
                        case <-time.After(time.Second * 3):
                        case <-timer.C:
                                openlog.Info("Sleep three second")
                        }
                        timer.Reset(time.Second * 3)
                }
                dubbConn := d.connMgr.GetConnection(conn)
                dubbConn.Open()
        }
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to