Important: Please read the Qt Code of Conduct -

Memory leak when using sourceSize on images in list views?

  • Hi.

    I'm having memory problems in my application that appears to be due to using sourceSize on images in list views. I've included a small QML-example below that illustrates the issue. It requires a bunch of images in the current directory, which I have not included.

    When scrolling to the end or the beginning of a list view, I expect to see the memory allocation of qmlscene to drop, since list items are released. When setting sourceSize equal to the image size, the allocation increases for each image coming into view, but never decrease. Scrolling back and forth for a while seems to increase the memory use more and more.

    However, setting the sourceSize to something different than the image size (such as five times larger), does show the expected behaviour at the end and beginning of the lists.

    Thing is, in my real application, I'm changing out loads of list items at fast rates in list views, and the memory consumption goes through the roof, since list items (or at least the pixmaps in them) that I expect to go away linger somewhere.

    Could someone confirm/speculate a bit on if this is indeed a memory leak in Qt and if I should file a bug report, or is this some sort of feature or effect of how sourceSize is supposed to work?

    import QtQuick 2.0
    import Qt.labs.folderlistmodel 2.1

    Rectangle {
    id : viewer
    width: 800
    height: 480

    ListModel {
        id : picSrcList
    FolderListModel {
        id: folderModel
        nameFilters: ["*.png", "*.jpg"]
    Component {
        id : picDelegate
        Image {
            id: dynamicImage
            source: fileName
            sourceSize.width: dynamicImage.width // * 5
            sourceSize.height: dynamicImage.height // * 5
            width: 200
            height: 200
    ListView {
        id: picListView
        anchors.fill: parent
        delegate: picDelegate
        model: folderModel
        orientation: ListView.Vertical


    Win7, Linux, 5.2, 5.3
    Possibly related to

Log in to reply