Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved Memory Management in Qml

    QML and Qt Quick
    2
    2
    439
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      Saman19 last edited by

      Hello.
      I developed a program by Qt and Qml!
      My application has several window that works with stackview.
      every time clicked on button, stackview push new window and if clicked on back, pop window!

      in this case I confront memory leak...
      MainWindow memory is 23.7 MB
      page1: 32MB
      page3: 33.7

      agian back to main window
      MainWindow : 28MB
      page1: 33.8MB
      Page2: 33.8MB

      agian back to main window
      Page4:39.2MB
      MainWindow: 39.2MB

      each window that opens, the memory increases!
      How can solved this?

      My stackview Code :

      toolBar: BorderImage {
          border.bottom: 8
          source: "qrc:/Icons/toolbar.png"
          width: parent.width
          height: 70
          Rectangle {
              id: backButton
              width: opacity ? 60 : 0
              anchors.left: parent.left
              anchors.leftMargin: 20
              opacity: stackView.depth > 1 ? 1 : 0
              anchors.verticalCenter: parent.verticalCenter
              antialiasing: true
              height: 60
              radius: 4
              color: backmouse.pressed ? "#222" : "transparent"
              Behavior on opacity { NumberAnimation{} }
              Image {
                  anchors.verticalCenter: parent.verticalCenter
                  source: "qrc:/Icons/navigation_previous_item.png"
                  Text {
                      font.pixelSize: 42
                      Behavior on x { NumberAnimation{ easing.type: Easing.OutCubic} }
                      x: backButton.x + backButton.width + 20
                      anchors.verticalCenter: parent.verticalCenter
                      text: "back"
                      color: "white"
                      font.family: webFont.name
                  }
              }
              MouseArea {
                  id: backmouse
                  anchors.fill: parent
                  anchors.margins: -10
                  onClicked:
                  {
                      stackView.pop()
                      gc()
                  }
      
              }
          }
          Text {
              font.pixelSize: 42
              Behavior on x { NumberAnimation{ easing.type: Easing.OutCubic} }
              anchors.verticalCenter: parent.verticalCenter
              anchors.horizontalCenter: parent.horizontalCenter
              color: "white"
              text: "Irsa Soft"
              font.family: webFont.name
      
          }
      }
      StackView {
              id: stackView
              anchors.fill: parent
              // Implements back key navigation
              focus: true
              Keys.onReleased: if (event.key === Qt.Key_Back && stackView.depth > 1) {
                                   stackView.pop();
                                   destroyed()
                                   gc()
                                   event.accepted = true;
                               }
      
              initialItem: Item {
      
                  width: parent.width
                  height: parent.height
                  MainMenu {
                      anchors.fill: parent
                      onClicked : stackView.push({item:url,destroyOnPop:true})
                      onChangeToshowTraffic : stackView.push({item:url,destroyOnPop: true})
                      onChangeToSaveEnter: stackView.push({item:url,destroyOnPop: true})
                      onChangeTomission: stackView.push({item:url,destroyOnPop: true})
                  }
              }
      
          }
      
      1 Reply Last reply Reply Quote 0
      • W
        While_e last edited by

        I too ran into this type of issue. I am currently pushing/popping between two windows, and am slowly increasing the memory until the app crashes. You ever find any insights or solutions to this issue?

        1 Reply Last reply Reply Quote 0
        • First post
          Last post