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

QML garbage collector doesn't work correctly with Loader

    XMLWordPrintable

    Details

    • Platform/s:
      Linux/Wayland
    • Commits:
      c5085eb8905f1a3c070f866746110980e84be271 (qt/qtdeclarative/dev) 92513ee677f3f4576a875a9e3195b0007278dc5e (qt/qtdeclarative/5.12) d62437be7743bbb5d7697bf2d3bf4b74cc79223e (qt/qtdeclarative/5.15)

      Description

      Test.qml

      import QtQuick 2.12
      import QtQuick.Controls 2.12
      
      Item {
          id: root
          width: 600
          height: 600
          
          Loader {
              id: loader
              anchors.fill: parent
          }
          
          Button {
              text: "ClickMe"
              anchors.centerIn: parent
              property int imgIndex: 0
              onClicked: {
                  imgIndex = 0
                  loader.setSource("Collage.qml", {index: ++imgIndex % 4})
                  gc()
              }
          }
      }
      

      Collage.qm

      import QtQuick 2.12
      
      Image {
          width: 500
          height: 500
          property int index: 0
          fillMode: Image.PreserveAspectFit
          source: index + ".jpg"
          cache: false
      
          Image {
              width: 300
              height: 300
              anchors.centerIn: parent
              fillMode: Image.PreserveAspectFit
              source: index + 1 + ".jpg"
              cache: false
              Image {
                  width: 100
                  height: 100
                  anchors.centerIn: parent
                  fillMode: Image.PreserveAspectFit
                  source: index + 2 + ".jpg"
                  cache: false
              }
          }
      }
      

      For testing, I used large pictures and a script of mouse clicks every 40 ms.

      If you click on the button a lot and quickly, then the memory is completely filled and the application crashes qt_output . If the clicks are slow, then everything works fine.
      Is it possible to forcibly delete already unused objects?

        Attachments

        1. 92513ee.diff
          2 kB
        2. qt_output
          1.03 MB
        3. Test.workaround.qml
          0.6 kB

          Issue Links

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

            Activity

              People

              Assignee:
              max.goldstein Maximilian Goldstein
              Reporter:
              evgeniy_kolchin Kolchin Evgeny
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes