chenshuo / muduo

Event-driven network library for multi-threaded Linux server in C++11
https://github.com/chenshuo/muduo
Other
14.7k stars 5.15k forks source link

fixbug: Channel memory leak #519

Closed alanskind closed 3 years ago

alanskind commented 3 years ago

Hi, I found that there is no 'delete' corresponding to the 'new Channel', and this will prevent the dtor of TcpConnection from being called (for there is a tied object in the class Channel). I have added a delete statement in function 'TcpConnection::connectDestroyed' because it is the last function called before the dtor of TcpConnection. And we can't add the delete statement in the dtor of TcpConnection because it won't be called (reason in the above). Hope that's helpful.