Important: Please read the Qt Code of Conduct -

QML ListView memory performance

  • Hi all,
    in my application (Qt 5.4.2 / QtQuick 2.4), I use ListView to display a more or less big list of items (about 2K elements).
    The ListView items are loaded with usage of model and delegate.
    The model is implemented in C++ (based on QAbstractListModel), and works fine.
    I also have implemented a QSortFilterProxyModel to add some filtering/sorting functions.

    In fact, the ListView can only display 5 elements on the screen and I have to scroll to see all the elements.

    In my delegate Component, I have added traces in Component.onCompleted and Component.onDestruction to follow to loading/destruction of each list item.
    I am surprised to see that all the items from my model are first loaded (2134 elements!!!) and then, when the ListView is displayed, the most of the are distroyed (about 2100 elements!!!).

    Then when I move the scrollbar, I can see in debug log then elements are loaded/destroyed according to my position in the list.

    The loading of the full list, followed by the destruction of 90% of those elements is are very time and memory consuming issue.
    Is there a workaround for this?
    Have I missed something in my ListView initialization?
    Here some extract from my QML item

    Item {
        id: root
        property alias model: tourList.model
        property Component tourListDelegate: TourListDelegate {}
        property bool enabledChacheBuffer: true
        ScrollBar {
            id: scrollBars
           ListView {
                id: tourList
                cacheBuffer: enabledChacheBuffer ? (height > 0 ? Math.min(height * 4, appSize.height * 1.5) : 0) : 0
                signal newCurrentIndex(int index)
                highlightMoveDuration: 300
                boundsBehavior: Flickable.StopAtBounds
                currentIndex: -1
                clip: false
                delegate: tourListDelegate
                    // When selecting element from list, ensure full element is visible
                    positionViewAtIndex(currentIndex, ListView.Contain)



  • How does the delegate implementation look like? Make sure it has a valid height at construction time, or else ListView will end up filling the view with 0-height delegate items.

  • @jpnurmi Thank's a lot! That's it :) Now everything works like a charm :)

    You saved my day!