[avahi] avahi-daemon memory leak

Thomas Fitzsimmons fitzsim at cisco.com
Wed Feb 13 13:17:00 PST 2013


Hi,

"Howard Lum (holum)" <holum at cisco.com>
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-avahi-daemon-work-around-libdbus-1-memory-consumpti.patch
Type: text/x-patch
Size: 4884 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/avahi/attachments/20130213/9b073068/attachment.bin>


More information about the avahi mailing list