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

QDeclarativeState leaks QDeclarativeBindings in some scenarios

XMLWordPrintable

    • 8570c509f505a4b238905122645a80faa768adb5

      I made a test app that has three Pages and utilizes a PageStack to navigate to
      some pages and back automatically, repeatedly.

      The memory consumption of the application keeps rising at a steady pace,
      apparently without any limit. When investigating the heap with massif, the 2nd
      most increase in heap usage was from QDeclarativeBinding constructor.

      After some investigation, to me it seems like the leak is in function
      QDeclarativeState::apply(). The leaking binding is stored first in
      action.fromBinding (line 629 of qdeclarativestate.cpp), then in some
      circumstances it is not deleted, but further stored into additionalReverts and
      further to d->revertList. When doing the actual transition in
      QDeclarativeTransitionManager::transition(), the binding is removed from the
      property, and thus not released when the property is destroyed. The revertList
      is lost when the QDeclarativeState is destroyed.

      I made a small change (attached) causing the memory to be released and re-ran my tests
      with the modified Qt libraries. Memory usage of both versions visualized in the
      attachment; green without this patch, blue with this patch.

      I also tried other QML apps with the patch in place and didn't notice any problems.

        1. memleakfix.patch
          0.9 kB
        2. memleak.png
          memleak.png
          6 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            brasser Michael Brasser (closed Nokia identity) (Inactive)
            jupakari Juuso Pakarinen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes