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

GC doesn't correctly account for C++ constructed pointers

    XMLWordPrintable

Details

    Description

      Try run the attached project. You'll notice that every loop iteration, there is at least 100000 (as set by the number of iterations in main.qml) instances of MyObject live.

      This is extraordinarily high, considering the objects are under JS ownership (due to being returned from C++ with no pointer), and unused after each iteration of the loop.

      What is interesting is that by setting QT_LOGGING_RULES="qt.qml.gc*=true", it is possible to see that multiple GCs run during the loop, but nothing "extra" above that loop count is ever freed. Playing with an explicit gc() after the loop, or QQmlEngine::setObjectOwnership() doesn't seem to change anything.

      Not sure exactly where the blame for this lies - the allocation isn't coming directly from the GC, after all, but since the objects should have JS ownership, I would expect them to be freed at some point, ideally even on the GCs during the loop's running.

      Attachments

        1. main.cpp
          1 kB
        2. main.qml
          0.6 kB
        3. qtalloctest.pro
          0.7 kB
        4. staircase.png
          staircase.png
          149 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qtqmlteam Qt Qml Team User
            w00t Robin Burchell
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes