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

Constant memory growth when creating and destroying QQuickViews (possible memory leak)

    XMLWordPrintable

Details

    • dd40295c31cacb2560e5c1ac25e217fd497600a3 ab79e832e602b6366340151720b8c7c7b7ddb1a3

    Description

      Please run the attached example.
      On Windows Task Bar Manager will report (in the Private Working set area) the following memory usages:
      1) Immediately after starting the application it will be ~5MB;
      2) After pressing the "Show Model Window" button and a QQuickView window opens the memory will get to ~35 MB;
      3) Pressing the "Reset Model" button, scrolling the QQuickView window, closing and re-opening it several times in no matter what order will constantly request more and more memory;
      4) Closing the QQuickView window will eventually release ~2 MB, but after re-opening it the memory consumption will increase back;
      5) Memory consumption eventually stabilizes with a ~5 MB increase on Windows and ~7 MB on Mac OS X from the moment QQuickView window was opened.
      6) No memory decrease was noticed after pressing the "Reset Model" button.
      7) Doing some debugging with WinDbg I noticed constant calls to VirtualAlloc and no VirtualFree calls for all the above operations, except closing and re-opening the QQuickView window. Tracing the calls to VirtualAlloc/VirtualFree lead me to WTF::OSAllocator::reserveAndCommit / WTF::OSAllocator::releaseDecommitted from Qt5Qml module. When closing the QQuickView window apparently OSAllocator releases the same amount of memory allocated with VirtualAlloc, but figures reported by Task Bar manager might suggest that some memory is kept somewhere else as well and is not released when QQuickView window gets destructed.

      This is a highly important issue for our production code, because our application can deal with dozens of such QQuickView windows and more complex UIs inside, which results in memory increases at a way more larger scale than what current demo project exhibits so those 5 MB increase are really important for us to understand where they came and how workaround this. Thank you!

      Attachments

        1. qtbug41588_purify.tasks
          165 kB
        2. qtbug41588_purify.txt
          185 kB
        3. qtbug41588_valgrind.txt
          34 kB
        4. qtbug41588.zip
          6 kB
        5. TestMemoryGrowth.zip
          6 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              Unassigned Unassigned
              vcernobai Victor Cernobai
              Votes:
              2 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes