Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [solved] QML increasing memory usage
QtWS25 Last Chance

[solved] QML increasing memory usage

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 2.6k Views
  • 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 Offline
    S Offline
    SteveKing
    wrote on last edited by
    #1

    I've been trying to use a loader to load different QML 'pages' in my application and have found that eventually it runs out of memory. From running this through a memory analyzer it seems that the number of QScriptObject::Data and QScript::QVariantDelegate seem to keep increasing. The simple code is shown at the bottom.

    You'll see from this that I've also tried using a page / page stack from the QML components, but this uses memory even faster!

    @Rectangle {
    id: mainItem
    anchors.fill: parent

    Timer {
       running: true
       interval: 500
       repeat: true
       property bool p1: true
       onTriggered: {
          if (p1)
          {
             console.log("A")
             p1 = false
             //localPageStack.push(page2)
             pageShow.sourceComponent = page2
          }
          else
          {
             console.log("B")
             p1 = true
             //localPageStack.pop()
             pageShow.sourceComponent = page1
          }
       }
    }
    
    Component {
       id: page1
       // Page {
       Rectangle {
          anchors.fill: parent
          Rectangle {
             anchors.fill: parent
             color: 'white'
             Text {
                text: "Hello"
             }
          }
       }
    }
    Component {
       id: page2
       //Page {
       Rectangle {
          anchors.fill: parent
          Rectangle {
             anchors.fill: parent
             color: 'white'
             Text {
                text: "Goodbye"
             }
          }
       }
    }
    
    Loader {
       id: pageShow
       anchors.fill: parent
       sourceComponent: page1
    }
    
    //Component.onCompleted: localPageStack.push(page1)
    
    //screen area
    //PageStack {
    //  id: localPageStack
    //  anchors.fill: parent
    //}
    

    }
    @

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SteveKing
      wrote on last edited by
      #2

      Looks like the function @gc()@ works for the loader case...

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved