You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by GitBox <gi...@apache.org> on 2021/08/30 12:44:21 UTC

[GitHub] [servicecomb-mesher] chenwei113524 opened a new pull request #148: time.After会形成内存泄漏

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-unsubscribe@servicecomb.apache.org

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



[GitHub] [servicecomb-mesher] tianxiaoliang merged pull request #148: time.After会形成内存泄漏

Posted by GitBox <gi...@apache.org>.
tianxiaoliang merged pull request #148:
URL: https://github.com/apache/servicecomb-mesher/pull/148


   


-- 
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-unsubscribe@servicecomb.apache.org

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



[GitHub] [servicecomb-mesher] tianxiaoliang merged pull request #148: time.After会形成内存泄漏

Posted by GitBox <gi...@apache.org>.
tianxiaoliang merged pull request #148:
URL: https://github.com/apache/servicecomb-mesher/pull/148


   


-- 
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-unsubscribe@servicecomb.apache.org

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



[GitHub] [servicecomb-mesher] tianxiaoliang commented on pull request #148: time.After会形成内存泄漏

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on pull request #148:
URL: https://github.com/apache/servicecomb-mesher/pull/148#issuecomment-908856923


   需要清理下静态检查告警


-- 
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-unsubscribe@servicecomb.apache.org

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



[GitHub] [servicecomb-mesher] tianxiaoliang commented on pull request #148: time.After会形成内存泄漏

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on pull request #148:
URL: https://github.com/apache/servicecomb-mesher/pull/148#issuecomment-908856923


   需要清理下静态检查告警


-- 
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-unsubscribe@servicecomb.apache.org

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