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

Memory leak when loading QML files with warnings

    XMLWordPrintable

Details

    • 1e0685136d0debb2a3b62d9f4650c95afe41913b (5.9.1) bd5345637453697269bb20bd8d25128432ea8265 (5.6.3)

    Description

      Each QML warning that is produced e.g. when loading a component or in JavaScript seems to be stored forever in some internal list and is never released.

       
      Run qmlscene Test.qml:

      Test.qml
      import QtQuick 2.5
      
      Rectangle {
          id: root
          color: "gray"
      
          width: 600
          height: 400
      
          MouseArea {
              anchors.fill: parent
              onClicked: {
                  ldr.current = 0;
                  tmr.restart();
              }
      
              Loader {
                  id: ldr
                  anchors.right: parent.right
                  anchors.bottom: parent.bottom
      
                  property int current: 0
      
                  onLoaded: {
                      current++;
                      if (current < 100000) {
                          tmr.restart();
                      }
                  }
              }
      
              Timer {
                  id: tmr
                  repeat: false
                  running: false
                  interval: 0
                  onTriggered: {
                      ldr.setSource("Warning.qml", { text: ldr.current });
                  }
              }
          }
      }
      

      that loads Warning.qml:

      import QtQuick 2.5
      
      Rectangle {
          id: root
      
          property alias text: txt.text
          property var xx: null
          
          color: "white"
          width: 80
          height: 40
      
          Text {
              id: txt
              anchors.centerIn: parent
          }
      
          Component.onCompleted: {
              if (root.xx.y === 0) {
                  console.log("asdd");
              }
          }
      }
      

      And watch the memory grow. On my machine, the memory consumption grows by about 500 byte/load.

      This issue leads to fast memory growth when a component is repeatedly loaded as a list delegate or an external event triggers a similar warning.

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            alexbusenius Alex Busenius
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes