Hello,
I simply added a loop to the dbus method call (MethodProxy add_proxy) and monitored the memory consumption in about 10 minutes of execution with valgrind.
The results are those in the following graph: there is an evident and constantly growing memory leak caused by the allocation/reallocation functions of the dbus layer.
I've been using different version of dbus library and the problem is always showing up.
The graph has been produced with the latest stable version of DBus (1.10.18) and the latest trunk version of dbus-cxx (r237).
Now, since the underlying DBus problem can be hard to find out, a temporary patch could be to periodically destroy and reconstruct the instantiated DBus::Connection and DBus::Dispatcher to free the memory allocated by DBus.
I tried putting all the example code in a scope and repeating this procedure twice: this way the DBus::Dispatcher::pointer, DBus::Connection::pointer, DBus::ObjectProxy::pointer and DBus::MethodProxy instances will be destroyed on scope exit.
Unfortunately the outcome of this solution is the same: memory isn't freed on scope exit (less iterations have been executed in case).
There are two possible causes to this behaviour: either dbus-cxx library isn't correctly calling the dbus functions responsible of the deletion of the instantiated dbus objects or dbus actually leaks memory at some points.
Have you ever noticed such behaviour before or investigated on similar cases?
Thanks in advance.
You can find the code used for the test
here.
Best regards,
Marco Nicolosi