palacaze / sigslot

A simple C++14 signal-slots implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Potential memory leak when weak_ptr compatible object used.

4e4o opened this issue · comments

commented

When signal connected to multiple shared_ptr objects there is no way to delete dead slots with dead objects without invoking slots. Every signal::connect call will increase slot instances. I think signal::connect with weak_ptr should check for dead slots and remove them.

Hi, I agree that dead slots removal gets delayed until the next signal emission.
Your proposed fix seems fine to me, but I would like to know if this is a real problem for you or just from a theoretical standpoint?

commented

Hi, I agree that dead slots removal gets delayed until the next signal emission. Your proposed fix seems fine to me, but I would like to know if this is a real problem for you or just from a theoretical standpoint?

Yes, there is a real problem. I have tcp server which produces tcp clients and i want to close all tcp clients when server closed. So i connect server stop signal to every new tcp client deleter, but signal emition is never happen actualy, only at program exit so i have a memleak.