Subject: [Boost-bugs] [Boost C++ Libraries] #4089: Memory leak in Boost.Signals2 when the signal is not invoked
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-04-12 16:56:11
#4089: Memory leak in Boost.Signals2 when the signal is not invoked
------------------------------------+---------------------------------------
Reporter: dan.berindei@⦠| Owner: fmhess
Type: Bugs | Status: new
Milestone: Boost 1.43.0 | Component: signals2
Version: Boost 1.42.0 | Severity: Problem
Keywords: |
------------------------------------+---------------------------------------
The attached program leaks memory by attaching and detaching slots from a
signal in a loop:
{{{
boost::signals2::signal<void(void)> sig;
boost::signals2::connection conn1, conn2, conn3, conn4;
while (true) {
conn1.disconnect();
conn2.disconnect();
conn1 = sig.connect(slot);
conn2 = sig.connect(slot);
conn3.disconnect();
conn4.disconnect();
conn3 = sig.connect(slot);
conn4 = sig.connect(slot);
//sig();
}
}}}
Invoking the signal (i.e. uncommenting the 'sig()' line) plugs the memory
leak, however in my original setting it entails lots of unnecessary work
so it's not a very good solution.
My guess is that _garbage_collector_it is set to
_shared_state->connection_bodies().end() on invocation, but not on a new
connection, so it never goes back to the beginning of the list.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/4089> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:02 UTC