Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-23582

QDBusConnection::unregisterObject does not free all of the used memory.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • 5.2.1
    • 4.7.4, 4.8.0
    • D-Bus
    • None
    • OpenSUSE + CentOs 6

    Description

      By looking at the memory usage of QDBusConnection it seems that over time it is using an increasing amount of memory when Objects are dynamically registered and unregistered. The memory consumption was detected using Massif, valgrind's heap profiler.

      Looking at the Qt code in QDBusConnection::unregisterObject() shows that when an object is unregistered it first tries to find the corresponding node (ObjectTreeNode) for the path and then resets the node. However the node that was found itself is never removed and stays in memory indefinitely. The node may not be used ever again. This can become problematic over a longer period of time.

      I have created a small test application to be able to target this issue specifically (see attaches source files). The application continuously registers and unregisters an object at D-Bus. Using a heap profiler shows that memory consumption is increasing. When applying a small patch to the Qt sources to remove the node itself in the described situation, the incrementation of the memory consumption disappears. I didn't add the patch here (yet) because it probably has some unwanted side effects.

      Attachments

        1. main.cpp
          0.5 kB
        2. testobject.cpp
          0.5 kB
        3. testobject.h
          0.4 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            smit Danny Smit
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes