Important: Please read the Qt Code of Conduct -

Qt/QML Image memory consumption

  • Hi everyone, I work on an application that consists in a series of small minigames and has a QQuickView that loads a main.qml file with a Loader element. We use this Loader to swich between the minigames and they have lots of images. The problem is that the memory used to render the image elements isn't being released. I made a small sample qml aplication that keeps switching the current component in a loader to simulate our application behaviour:

    import QtQuick 2.7
    Item {
        id: root
        width: 1920
        height: 1080
        Component {
            id: image1Component
            Image {
                source: "00-piscina.png"
                anchors.fill: parent
        Component {
            id: image2Component
            Image {
                source: "01-canyon.png"
                anchors.fill: parent
        Loader {
            id: loader
            sourceComponent: image1Component
            anchors.fill: parent
        Timer {
            repeat: true
            interval: 100
            running: true
            onTriggered: {
                loader.sourceComponent = loader.sourceComponent == image1Component ? image2Component : image1Component;

    When I run this code, the allocated memory keeps going up until my laptop freezes. The Loader element documentation stated that "If the source or sourceComponent changes, any previously instantiated items are destroyed", so, the allocated memory for images should be released, right?

    I also ran some tests using massif to see what is allocating memory, and these are my results:

    Running using qmlscene:



    Running using qmlscene --software (tryng to change rendering to see if results would be different):

    Loading the same main.qml file using the following main.cpp:

    #include <QtQuick/QQuickView>
    #include <QGuiApplication>
    int main(int argc, char *argv[])
        QGuiApplication app(argc, argv);
        QQuickView view;
        return app.exec();



    I'm not sure this is s a leak, but I'll start digging bug reports, thanks in advance if someone expeperienced the same problem and know a workaround for this

  • Qt Champions 2017

    Sounds like a bug. This is a user forum and you'd probably have more luck asking your question in the mailing list, where you can find some of Qt's developers. So I suggest you try that if no one here has anything to add in the following few days.

  • Asked for help on the mailing lists and looks like it's a new issue, I created a bug report for it.

    mailing list thread:
    bug report:

  • Qt Champions 2017

    Thank you for posting your findings here as well!

  • The bug is related to and I confirmed that this patch fixes the problem:

Log in to reply