Hi,

"Howard Lum (holum)" <[email protected]>
writes:

> We are seeing a memory leak of about 880 kB per day in avahi-daemon 0.6.24. We
> upgraded to 0.6.31 and the leak seems to have gone down to about 500 kB per
> day. Has anyone seen this before?
>
>  
>
> Here are some additional details about our setup.
>
> 1.       We are running on an embedded system without X11.
>
> 2.       We have an instance of dbus-daemon running with the --system option
> and another one running with the --session option.
>
> 3.       We are using the allow-interfaces configuration option to limit
> traffic to a VLAN that we have created. IP addresses on the VLAN are obtained
> using avahi-autoipd.
>
> 4.       Running with the --debug option, we see the following messages
> periodically.
> dbus-protocol.c: interface=org.freedesktop.Avahi.Server, path=/,
> member=GetAPIVersion
> dbus-protocol.c: interface=org.freedesktop.Avahi.Server, path=/,
> member=GetState
> dbus-protocol.c: interface=org.freedesktop.Avahi.Server, path=/,
> member=ServiceBrowserNew
> dbus-protocol.c: client :1.52584 vanished.

It turns out this is a memory consumption issue in libdbus-1 to which
avahi-daemon is particularly susceptible, because of the way it
registers and unregisters object paths.

I posted my full analysis to the D-Bus mailing list:

http://lists.freedesktop.org/archives/dbus/2013-January/015443.html

and filed a bug report against D-Bus:

https://bugs.freedesktop.org/show_bug.cgi?id=60176

We've tested the attached patch against avahi-daemon and have confirmed
that it eliminates the increase in memory consumption.  The patch
collapses Client%u and service path elements into one top-level node by
removing the '/' separator.  Neither avahi-daemon nor the client tools
rely on the path format, so functionality is unaffected; non-leaf nodes
are never created in the D-Bus object tree so they don't linger in
memory indefinitely.

I'm posting this workaround mostly for reference -- I'm not sure it
should be applied to avahi.  avahi-daemom isn't doing anything wrong --
it properly unregisters each path that it registers.  It's just that
libdbus-1's dbus_connection_unregister_object_path isn't as aggressive
as it should be in freeing newly-childless parent nodes.  The root cause
should be fixed in libdbus-1, since other services may also be affected.

Thomas
>From b3bc73fb318d5a92885e8133002c4f46facb5205 Mon Sep 17 00:00:00 2001
From: Thomas Fitzsimmons <[email protected]>
Date: Wed, 13 Feb 2013 15:55:25 -0500
Subject: [PATCH] avahi-daemon: work around libdbus-1 memory consumption bug

This is a workaround for https://bugs.freedesktop.org/show_bug.cgi?id=60176.
We collapse Client%u and service D-Bus object path elements into one top-level
node by removing the '/' separator.  That way non-leaf nodes are never created
in the D-Bus object tree, and thus don't linger in memory indefinitely.
---
 avahi-daemon/dbus-protocol.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/avahi-daemon/dbus-protocol.c b/avahi-daemon/dbus-protocol.c
index eb8a662..f2f4562 100644
--- a/avahi-daemon/dbus-protocol.c
+++ b/avahi-daemon/dbus-protocol.c
@@ -453,7 +453,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH
             return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL);
         }
 
-        i->path = avahi_strdup_printf("/Client%u/EntryGroup%u", client->id, i->id);
+        i->path = avahi_strdup_printf("/Client%uEntryGroup%u", client->id, i->id);
         dbus_connection_register_object_path(c, i->path, &vtable, i);
         return avahi_dbus_respond_path(c, m, i->path);
 
@@ -596,7 +596,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH
             return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL);
         }
 
-        i->path = avahi_strdup_printf("/Client%u/DomainBrowser%u", client->id, i->id);
+        i->path = avahi_strdup_printf("/Client%uDomainBrowser%u", client->id, i->id);
         dbus_connection_register_object_path(c, i->path, &vtable, i);
         return avahi_dbus_respond_path(c, m, i->path);
 
@@ -651,7 +651,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH
             return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL);
         }
 
-        i->path = avahi_strdup_printf("/Client%u/ServiceTypeBrowser%u", client->id, i->id);
+        i->path = avahi_strdup_printf("/Client%uServiceTypeBrowser%u", client->id, i->id);
         dbus_connection_register_object_path(c, i->path, &vtable, i);
         return avahi_dbus_respond_path(c, m, i->path);
 
@@ -707,7 +707,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH
             return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL);
         }
 
-        i->path = avahi_strdup_printf("/Client%u/ServiceBrowser%u", client->id, i->id);
+        i->path = avahi_strdup_printf("/Client%uServiceBrowser%u", client->id, i->id);
         dbus_connection_register_object_path(c, i->path, &vtable, i);
         return avahi_dbus_respond_path(c, m, i->path);
 
@@ -820,7 +820,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH
 
 /*         avahi_log_debug(__FILE__": [%s], new service resolver for <%s.%s.%s>", i->path, name, type, domain); */
 
-        i->path = avahi_strdup_printf("/Client%u/ServiceResolver%u", client->id, i->id);
+        i->path = avahi_strdup_printf("/Client%uServiceResolver%u", client->id, i->id);
         dbus_connection_register_object_path(c, i->path, &vtable, i);
         return avahi_dbus_respond_path(c, m, i->path);
 
@@ -873,7 +873,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH
             return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL);
         }
 
-        i->path = avahi_strdup_printf("/Client%u/HostNameResolver%u", client->id, i->id);
+        i->path = avahi_strdup_printf("/Client%uHostNameResolver%u", client->id, i->id);
         dbus_connection_register_object_path(c, i->path, &vtable, i);
         return avahi_dbus_respond_path(c, m, i->path);
 
@@ -929,7 +929,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH
             return avahi_dbus_respond_error(c, m, avahi_server_errno(avahi_server), NULL);
         }
 
-        i->path = avahi_strdup_printf("/Client%u/AddressResolver%u", client->id, i->id);
+        i->path = avahi_strdup_printf("/Client%uAddressResolver%u", client->id, i->id);
         dbus_connection_register_object_path(c, i->path, &vtable, i);
         return avahi_dbus_respond_path(c, m, i->path);
 
@@ -994,7 +994,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, AVAH
 
         avahi_key_unref(key);
 
-        i->path = avahi_strdup_printf("/Client%u/RecordBrowser%u", client->id, i->id);
+        i->path = avahi_strdup_printf("/Client%uRecordBrowser%u", client->id, i->id);
         dbus_connection_register_object_path(c, i->path, &vtable, i);
         return avahi_dbus_respond_path(c, m, i->path);
     }
-- 
1.6.0.6

_______________________________________________
avahi mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/avahi

Reply via email to