Important: Please read the Qt Code of Conduct -

Loader Element

  • When using a loader element to navigate to a new page is the page that has the loader event on it still loaded? In other words, if I just keep doing loader events to navigate from page to page will I run into memory issues eventually?

  • "To unload the currently loaded item, set this property to an empty string, or set sourceComponent to undefined."

    see more info here: "Loader":

    Not sure if you change the source to a different qml file, if it unloads the previous item. maybe someone from nokia stuff can answer that.

  • It would be great information to know.

  • I think it will unload the current qml item, but the best way to test it is to make a script to load 1000 times a qml file and see if there are any memory changes :)

  • I found that it does introduce memory problems. If anyone knows of an unload that would be the preferable way to fix it. Otherwise, would this be better:

    @Connections {
            target: myLoader.item
            onMessage: console.log(msg)

    with the changePage() call?

  • Are you sure? because I did a test myself and didn't find any memory problem. however to unload a page just use this


    read more on the source property on Loader page.
    I think that if you change the source page it will do just fine. :)

  • Setting the source to a new url will cause the item created by the previous url to be deleted (it uses deleteLater(), so it's possible that if you did this in a loop, you would see memory increase until the event loop was entered again).

    I've updated the docs to clarify this.


  • Thanks for the help.

Log in to reply