dbus valgrind memcheck

Simon McVittie simon.mcvittie at collabora.co.uk
Mon Jun 3 12:56:50 PDT 2013


On 03/06/13 20:22, Ernast Sevo wrote:
> I am quite new to DBus and have been writing an application that uses DBus.
> To be safe I have been putting my application through some checks with Valgrind
> and I get the following output:
...
> ==323==    still reachable: 12,955 bytes in 63 blocks

Having some memory that is still reachable on exit is normal. libdbus
has some global memory allocations that are never freed (but after a
while, the amount of memory used in this way should stop increasing).

One good way to see whether "still reachable" memory is a problem is to
vary the number of repetitions. If you run your test 100, 1000, 5000
times, and the "still reachable" memory is similar in all cases, then
everything is fine. If the "still reachable" memory is close to 10x as
much when you run 1000 times and close to 50x when you run 5000 times,
then you probably have a memory leak.

It is possible to build a developer version of libdbus which has worse
performance and potentially worse security, but produces "cleaner"
valgrind results. See
<http://cgit.freedesktop.org/dbus/dbus/tree/README.valgrind> (or
README.valgrind in a source tarball) for details.

Please note that you can only call dbus_shutdown() if all threads in
your process except the main thread have terminated, and nothing else in
your process (including libraries, plugins and so on) is using libdbus.
Calling it just before main() exits is usually OK.

    S



More information about the dbus mailing list