Sure,

This example I've just created and it does exactly what I want to show.

greetings and thanks for your support

There are 2 buttons, one populates the model with 25000 simple items. 

The second one pushes a page above the page with listview. After the
push you can see the ListView creating lots of delegates in console.log

PS.: I've not tested it with qmlscene but as an application
(modeltext.tar.xz) on real device.


Am Sonntag, den 15.12.2013, 20:25 +0000 schrieb Robin Burchell:
> Can you please provide a minimal test case (i.e. ideally a single QML file, 
> usable with qmlscene) demonstrating your problem?
> 
> Please see http://sscce.org/
> 
> On 15 Dec 2013, at 21:03, Hendrik Borghorst <[email protected]> 
> wrote:
> 
> > Hello,
> > 
> > the problem isn't my delegate. It is quite minimal. 
> > 
> > The problem is I think a bug in QML Listview. It goes absolutly crazy if
> > it is invisible and starts making delegate for around 50% of all items.
> > This causes the memory to run full.
> > 
> > A workaround I added is
> > 
> > model: visible ? modelVar : null
> > 
> > which works quite nicely. I think this bug could be an upstream qt bug?
> 
> > 
> > greetings
> > 
> > Am Sonntag, den 15.12.2013, 10:01 +0100 schrieb
> > [email protected]:
> >> Hi Hendrik
> >> 
> >> Have you seen this? http://qt-project.org/wiki/Performance_tip_Lists
> >> 
> >> The general advice is to keep the delegates is lightweight as  
> >> possible, and to use Loaders for anything needed later (e.g. onClick)
> >> 
> >> Chris
> >> 
> >> Zitat von "Hendrik Borghorst" <[email protected]>:
> >> 
> >>> Hello folks,
> >>> 
> >>> I've got a problem with long lists (~25000 elements). All delegates are
> >>> created at once which causes the memory usage to explode beyond the
> >>> devices capability.
> >>> 
> >>> I already tried setting "cacheBuffer: 0" in SiliciaListView but  it
> >>> doesn't change it.
> >>> 
> >>> Is the something I'm doing wrong.
> >>> 
> >>> You can see the actual page code here:
> >>> 
> >>> https://github.com/djselbeck/smpc/blob/master/pages/CurrentPlaylistPage.qml
> >>> 
> >>> Shouldn't the delegates be constructed on demand? It is weird because my
> >>> old n8 wasn't struggling with qml lists with this size.
> >>> 
> >>> greetings and congrats on getting the devices to your customers (I'm
> >>> very pleased)
> >>> 
> >> 
> >> 
> >> 
> >> 
> > 
> > _______________________________________________
> > SailfishOS.org Devel mailing list
> 
> _______________________________________________
> SailfishOS.org Devel mailing list

import QtQuick 2.0
import Sailfish.Silica 1.0

ApplicationWindow {
    Component {
        id: mainPage
        Page {
            SilicaListView {
                id: listView
                anchors {
                    top: parent.top
                    bottom: buttonRow.top
                    left: parent.left
                    right: parent.right
                }

                delegate: Component {
                    ListItem {
                        Row {
                            Label {
                                text: index
                            }
                            Label {
                                text: value
                            }
                        }
                        Component.onCompleted: {
                            console.debug("Created delegate: " + index)
                        }
                    }
                }
            }
            Row {
                id: buttonRow
                anchors {
                    bottom: parent.bottom
                    right: parent.right
                    left: parent.left
                }

                Button {
                    text: "populate"
                    onClicked: {

                        for (var i = 0; i <= 25000; i++) {
                            // Populate an model with some demo data
                            console.debug("populating: " + i)
                            testModel.append({
                                                 index: i,
                                                 value: "Some text"
                                             })
                        }
                        listView.model = testModel
                    }
                }
                /** The moment you press on this button
                  you can see console.log with delegate creations
                  */
                Button {
                    text: "new page"
                    onClicked: {
                        pageStack.push(emptyPage)
                    }
                }
            }

            // Empty model until populated
            ListModel {
                id: testModel
            }
        }
    }

    // Just an empty page for demonstration
    Component {
        id: emptyPage
        Page {
        }
    }

    initialPage: mainPage
}

Attachment: modeltest.tar.xz
Description: application/xz-compressed-tar

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
SailfishOS.org Devel mailing list

Reply via email to