Memory leak in dbus / dbus-c++ ?

Havoc Pennington hp at
Tue Jul 31 09:56:14 PDT 2007


Olivier Hochreutiner wrote:
> I checked that and it seems fine. Actually I remarked that
> dbus_connection_send_with_reply_and_block() returns a DBusMessage with
> refcount == 1, and the c++ binding calls dbus_message_ref() on it, and
> then later dbus_message_unref(), which means refcount is still 1 at
> the end and the message is not freed.

The caller of send_with_reply_and_block() should be calling unref() to 
remove the returned refcount. So if the C++ binding does a ref(), it 
should do two unref(), one for the ref() and one for the original refcount.

> I also remarked that the reply message returned by
> dbus_connection_send_with_reply_and_block() is also passed to the
> dispatcher. Is this expected ? It seems to me that this is not
> correct, since it's the reply to a known method call, so dispatching
> is not needed, or am I wrong ?

Filters installed on a connection have a chance to intercept every 
message, but normally they will not do anything with a method reply.

You might use this feature for e.g. debug output.


More information about the dbus mailing list