App freezes when unloading screen containing many components
I've done a couple of QML apps now, and both contain screens which need a large number of components added to them at runtime.
I add these components in a loop, using Qt.createComponent() and Component.createObject(). I use this to add anywhere between 50 and 200 components.
The problem comes when it's time to unload the screen. When the screen disappears, and the new one is loaded in, the app freezes for a few seconds. The more components that were added to the screen, the worse this gets.
I guess this is due to the system disposing of all the objects that were created.
The handset seems to freeze completely at this time, not accepting any touches, and not updating the screen at all. We also get no notice about when the cleanup process has finished.
Other than keeping these components loaded in memory at all times (risking us going out of memory at some other point), is there any way to get round this problem?