chenshuo / muduo

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

不Delete Channel是否会造成内存泄漏的问题 #615

Closed guang19 closed 2 years ago

guang19 commented 2 years ago

大神,我发现TcpConnection的CloseCallback最终执行的是connectDestroyed:

void TcpConnection::connectDestroyed()
{
  loop_->assertInLoopThread();
  if (state_ == kConnected)
  {
    setState(kDisconnected);
    channel_->disableAll();

    connectionCallback_(shared_from_this());
  }
  channel_->remove();
}

但这个函数仅仅是把channel从Poller和ChannelMap中移除,并不会delete Channel,我也没在其它任何地方找到delete Channel相关的代码,不知道这是否是一个内存泄漏问题?